I've got a bunch of "numbers" that have multiple decimal points (so they're really strings). However, I want to sort them as if they were numbers.
1.1.1
10.2.3
2.6.7
21.10.4
3.10.12
4.11.5
4.1.16
6.4.23
I want them to sort by the first set of numbers (before the first decimal point), then by the second set, then by the third (with the possibility of it continuing for a fourth set or more). They should go in this order:
1.1.1
2.6.7
3.10.12
4.1.16
4.11.5
6.4.23
10.2.3
21.10.4
What is the best way to do this using JS? I'm thinking I'll probably need to break each number into an array, but there maybe a better way. Ideas?
See Question&Answers more detail:os