Skip to content

Instantly share code, notes, and snippets.

@joshmyers
Created November 28, 2013 17:26
Show Gist options
  • Save joshmyers/52ece58f74cbc9932c0f to your computer and use it in GitHub Desktop.
Save joshmyers/52ece58f74cbc9932c0f to your computer and use it in GitHub Desktop.
~ $ pry
[1] pry(main)> a = [ "node2", "node3", "node4" ]
=> ["node2", "node3", "node4"]
[2] pry(main)> a.sort_by{ |n| n.gsub(/[^0-9]/, "").to_i }
=> ["node2", "node3", "node4"]
[3] pry(main)> a.first
=> "node2"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment