Compare numbers
Compare numbers:
With the asc
function: compare A and B, returns 1 if A is greater, -1 if lower, 0 if both are equal. Can be used with array.sort().
With the desc
function: compare A and B, returns -1 if A is greater, 1 if lower, 0 if both are equal. Can be used with array.sort().
Installation
npm install compare-numbers
How to use
Require compare-numbers:
var compareNumbers = ;
compareNumbers; // 1compareNumbers; // -1compareNumbers; // 0
compareNumbers; // -1compareNumbers; // 1compareNumbers; // 0
To be used with array.sort to sort arrays:
10 2 30 45 60; // [2, 10, 30, 45, 60];
10 2 30 45 60; // [60, 45, 30, 10, 2];
LICENSE
MIT