Created
September 19, 2011 20:23
-
-
Save dreamr/1227504 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
d=["2x4","2x6","4x4","4x10","2x8", "2x10"] | |
d.sort {|a,b| a.split("x") <=> b.split("x")} # doesnt work, nor any variations I can think of | |
# expected | |
["2x4","2x6","2x8","2x10","4x4", "4x10"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
d.sort {|a,b| a.split("x").map(&:to_i) <=> b.split("x").map(&:to_i)}