Last active
August 29, 2015 13:57
-
-
Save alexhawkins/4c7731afd7ae4b1da7d1 to your computer and use it in GitHub Desktop.
Sort a String of Random Numbers
This file contains 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
map_this_array = "1 2 3 19 23 234 523 323 325 53 533 234 14 78 68676 46 990 67845" | |
p map_this_array.split.map(&:to_i).sort{|x,y| x <=> y}.join(", ") | |
# yields => "1, 2, 3, 14, 19, 23, 46, 53, 78, 234, 234, 323, 325, 523, 533, 990, 67845, 68676" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment