UNPKG
monk-import-export
Version:
latest (0.0.0)
0.0.0
Simple import & export sorting ESLint plugin
monk-import-export
/
src
/
utils
/
compare.ts
6 lines
(4 loc)
•
206 B
text/typescript
View Raw
1
2
3
4
5
6
const
collator
=
new
Intl
.
Collator
(
'en'
, {
numeric
:
true
,
sensitivity
:
'base'
}); export
function
compare
(
a:
string
, b:
string
):
number
{
return
collator.
compare
(a, b) || (a < b ? -
1
: a > b ?
1
:
0
); }