Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2
You need to add a compare function "function(a, b){return a - b}". var ages = [40, 20, 33, 15, 25, 10]; ages.sort(function(a, b){return a - b}); You can follow the link below for further explanation https://www.w3schools.com/js/js_array_sort.asp
23rd Jul 2019, 1:44 PM
ODLNT
ODLNT - avatar