ascending order of array in javascript code example
Example 1: javascript sort by id
elems.sort((a, b) => a.id - b.id);
Example 2: sort by ascending javascript
const months = ['March', 'Jan', 'Feb', 'Dec'];
months.sort();
console.log(months);
// expected output: Array ["Dec", "Feb", "Jan", "March"]