Created
October 13, 2013 17:19
-
-
Save andersr/6964811 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unsorted_files = [ | |
"foo-1.10.2.ext", | |
"foo-1.11.ext", | |
"foo-1.3.ext", | |
"foo-1.50.ext", | |
"foo-1.8.7.ext", | |
"foo-1.9.3.ext", | |
"foo-1.ext", | |
"foo-10.1.ext", | |
"foo-10.ext", | |
"foo-100.ext", | |
"foo-13.ext", | |
"foo-2.0.0.ext", | |
"foo-2.0.1.ext", | |
"foo-2.0.ext", | |
"foo-2.007.ext", | |
"foo-2.01.ext", | |
"foo-2.012b.ext", | |
"foo-2.01a.ext", | |
"foo-2.0a.ext", | |
"foo-2.0b.ext", | |
"foo-2.1.ext", | |
"foo-25.ext", | |
"foo-6.ext", | |
] | |
class Array | |
def version_sort | |
sorted = self.collect {|file| file.split(".")}.sort | |
sorted.collect {|file| file.join(".")} | |
end | |
end | |
puts unsorted_files.version_sort | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment