How cool is that...amirite?
['a', 'a 20', 'a 1', 'a 2', 'a 12'].sort((a,b) => ("" + a).localeCompare(b, undefined, {numeric: true}));
['a', 'a 1', 'a 2', 'a 12', 'a 20']
NOT
['a', 'a 1', 'a 12', 'a 2', 'a 20']
😎
=> More informations about this toot | More toots from westbrook@mastodon.social
@westbrook That is cool! Had no idea about localeCompare
!!
=> More informations about this toot | More toots from jeremiak@journa.host
@jeremiak I'd been using it without the {numeric: true}
, and had no idea what I was missing. The web platform...huge!
=> More informations about this toot | More toots from westbrook@mastodon.social
@westbrook Totally! I feel like I'm learning about a new API nearly every week. The { numeric: true }
thing is the KEY!
=> More informations about this toot | More toots from jeremiak@journa.host This content has been proxied by September (3851b).Proxy Information
text/gemini