You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.js 372B

12345678910111213
  1. module.exports = function cmp (a, b) {
  2. var pa = a.split('.');
  3. var pb = b.split('.');
  4. for (var i = 0; i < 3; i++) {
  5. var na = Number(pa[i]);
  6. var nb = Number(pb[i]);
  7. if (na > nb) return 1;
  8. if (nb > na) return -1;
  9. if (!isNaN(na) && isNaN(nb)) return 1;
  10. if (isNaN(na) && !isNaN(nb)) return -1;
  11. }
  12. return 0;
  13. };