Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to sort an array

var carBrands = ["Toyota", "Jeep", "Ford", "Volvo"];
carBrands.sort();
// array.sort() method sorts an array in ascending order by default
// extend the function like below to sort in descending order or customize
//carBrands.sort(function(a, b){return b-a});
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #sort #array
ADD COMMENT
Topic
Name
2+6 =