We have a bunch of SomeItems
which have a field someId
which is in the format (simplified / replaced with dummies):
abc.def1.<someNumber>
I have an array of SomeItems
and have been sorting it like this:
let rows = someItems.sort((lhs, rhs) => lhs.someId > rhs.someId)
This pretty much just sorts it alphabetically, so this means that the order comes out a little weird:
abc.def1.1
abc.def1.1234
abc.def1.1235
abc.def1.2
abc.def1.234
I instead want it to be numerically sorted - like 1, 2, 234, 1234, etc.
What's a clean way to do this?