Skip to content

Instantly share code, notes, and snippets.

@xymbol
Created October 14, 2014 02:39
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 xymbol/ca04783d159a1d289a44 to your computer and use it in GitHub Desktop.
Save xymbol/ca04783d159a1d289a44 to your computer and use it in GitHub Desktop.
array = [
{ x: 1, y: 2 },
{ x: 2, y: 2 },
{ x: 3, y: 2 }
]
array.sort_by do |k, v|
[k, v] # => [{:x=>1, :y=>2}, nil], [{:x=>2, :y=>2}, nil], [{:x=>3, :y=>2}, nil]
0
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment