JavaScript: Sort the items of an array code example
Example 1: javascript sort by id
elems.sort((a, b) => a.id - b.id);
Example 2: javascript sort array in ascending order
//sorts arrays of numbers
function myFunction() {
points.sort(function(a, b){return a-b});
document.getElementById("demo").innerHTML = points;
}