Node.js examples for Math:Compare
Get Compare From Less Comparator
function numberLessComparator ( a, b ) { return a < b; } function numberCmpComparator ( a, b ) { return a - b;/* w w w .j a va2 s .co m*/ } function getCmpFromLessComparator ( lessComparator ) { return function ( a, b ) { if ( lessComparator( a, b ) ) return -1; if ( lessComparator( b, a ) ) return 1; return 0; }; } function getLessFromCmpComparator ( cmpComparator ) { return function ( a, b ) { return cmpComparator( a, b ) < 0; }; }