Skip to content

Instantly share code, notes, and snippets.

@yayitswei
Created March 22, 2013 07:34
Show Gist options
  • Select an option

  • Save yayitswei/5219593 to your computer and use it in GitHub Desktop.

Select an option

Save yayitswei/5219593 to your computer and use it in GitHub Desktop.
wei:classnotes wei$ irb
irb(main):001:0> a = [{:a=>1}, {:a=>2}]
=> [{:a=>1}, {:a=>2}]
irb(main):003:0> a.sort! {|a, b| a[:a] <=> b[:a]}
=> [{:a=>1}, {:a=>2}]
irb(main):004:0> b = [{:a => 1}]
=> [{:a=>1}]
irb(main):005:0> b.sort! {|a, b| a[:a] <=> b[:a]}
=> [{:a=>1}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment