I've got an array of string version numbers which I'd like to sort but can't for the life of me get them to sort the way I want:
versions = [ "1.0.4", "1.0.6", "1.0.11", "1.1.9", "1.1.10", "1.0.16" ]
versions.sort_by {|v| [v.size]}
=> ["1.0.4", "1.0.6", "1.1.9", "1.0.11", "1.1.10", "1.0.16"]
Trying to achieve:
=> ["1.0.4", "1.0.6", "1.0.11", "1.0.16", "1.1.9", "1.1.10"]
It seems to have something to do with lexicographically but I'm having difficulty working out the sorting rule I need to apply.
Any help or a point in the right direction would be greatly appreciated.