I have the following array of strings:
x = ["1.2", "1.1", "1.18", "1.18.3", "1.4", "1.18.20", "2.5"]
Ruby's Array sort method is sorting the strings alphabetically which results in this:
[
[0] "1.1",
[1] "1.18",
[2] "1.18.20",
[3] "1.18.3",
[4] "1.2",
[5] "1.4",
[6] "2.5",
]
I'd like to sort this array based on the numerical value within each decimal so that it returns the following order:
[
[0] "1.1",
[1] "1.2",
[2] "1.4",
[3] "1.18",
[4] "1.18.3",
[5] "1.18.20",
[6] "2.5"
]
I also can't guarantee the number of decimal points within each "ID". Any help would be greatly appreciated. Thanks!