Files
med-notes/.pnpm-store/v10/files/36/cfe8fab9422e57b3827655c2d5b24a4fde125b7daa12d934c4135f9957b3d7076d15a9f82cf3648734a4f10794c2add94065be8bb6f0056fcb05b5a55a9fef
2025-06-26 03:35:15 +00:00

26 lines
424 B
Plaintext

'use strict'
const numeric = /^[0-9]+$/
const compareIdentifiers = (a, b) => {
const anum = numeric.test(a)
const bnum = numeric.test(b)
if (anum && bnum) {
a = +a
b = +b
}
return a === b ? 0
: (anum && !bnum) ? -1
: (bnum && !anum) ? 1
: a < b ? -1
: 1
}
const rcompareIdentifiers = (a, b) => compareIdentifiers(b, a)
module.exports = {
compareIdentifiers,
rcompareIdentifiers,
}