Open sanjarcode opened 1 year ago
normal localeCompare sorts [1, 2, 10, 11] as [1, 10, 11, 2] (undesirable). of course, these are strings.
localeCompare
fix:
'10'.localeCompare('2', undefined, {numeric: true, sensitivity: 'base'})
source: https://stackoverflow.com/a/38641281/11392807 important
normal
localeCompare
sorts [1, 2, 10, 11] as [1, 10, 11, 2] (undesirable). of course, these are strings.fix:
source: https://stackoverflow.com/a/38641281/11392807 important