Global

Methods

customComparator(a, b) → {number}

Custom comparator example for all Collections
Example
// suppose data is of the form { age : 2 } , { age : 12 }....etc
function(a, b) {
   if(a.age < b.age) {
     return -1;
   } else if(a.age > b.age) {
     return 1;
   }
   return 0;
 }
Parameters:
Name Type Description
a * first element to compare
b * second element to compare
Returns:
-1 if a < b, 1 if a > b, and 0 if equal
Type
number

defaultComparator(a, b) → {number}

default comparator for all Collections
Example
function(a, b) {
   if(a < b) {
     return -1;
   } else if(a > b) {
     return 1;
   }
   return 0;
 }
Parameters:
Name Type Description
a number | string first element to compare
b number | string second element to compare
Returns:
-1 if a < b, 1 if a > b, and 0 if equal
Type
number