Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to sort an array of object

function compareFn(a, b) {
  if (a is less than b by some ordering criterion) {
    return -1;
  }
  if (a is greater than b by the ordering criterion) {
    return 1;
  }
  // a must be equal to b
  return 0;
}
Source by developer.mozilla.org #
 
PREVIOUS NEXT
Tagged: #sort #array #object
ADD COMMENT
Topic
Name
9+2 =