Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Sort an array by both ascending and descending order in js

var myArray = [1, 5, 8, 4, 0, 3, 6];
myArray.sort(); //[0, 1, 3, 4, 5, 6, 8]
myArray.reverse(); //[8, 6, 5, 4, 3, 1, 0]
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Sort #array #ascending #descending #order #js
ADD COMMENT
Topic
Name
9+4 =