Skip to content

Instantly share code, notes, and snippets.

@alexhawkins
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexhawkins/4c7731afd7ae4b1da7d1 to your computer and use it in GitHub Desktop.
Save alexhawkins/4c7731afd7ae4b1da7d1 to your computer and use it in GitHub Desktop.
Sort a String of Random Numbers
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