Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

sort function explained javascript

var sortedArray = myArray.sort(function(a,b){
                                   if (a.name < b.name)
                                      return -1;
                                   else if (a.name == b.name)
                                      return 0;
                                   else
                                      return 1;
                               });
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #sort #function #explained #javascript
ADD COMMENT
Topic
Name
4+4 =