this is my code. i need to take input from user into an array using split so that i can take multiple number in one form. Then sort them and show in ascending order. plz help
<!DOCTYPE html>
<html>
<body>
<script>
var notesArray = Array();
function array() {
let splits = document.getElementById("text1").value.split('~');
for (var i = 0; i < splits.length; i++) {
notesArray.push(splits[i]);
}
document.getElementById("text1").value = "";
}
function display_array() {
var e = "<hr/>";
for (var y = 0; y < notesArray.length; y++) {
e += "Element " + y + " = " + notesArray[y] + "<br/>";
}
document.getElementById("Result").innerHTML = e;
}
</script>
<form>
<input type="text" id="text1"></input><br>
<input type="button" id="button1" value="Add" onclick="array();"></input><br>
<input type="button" id="button2" value="Display" onclick="display_array();"></input><br>
<div id="Result"></div>
</form>
</body>
</html>
my function may not work here. what is the best way to do the sorting?