wilson (owner)

Revisions

gist: 174421 Download_button fork
public
Public Clone URL: git://gist.github.com/174421.git
Embed All Files: show embed
Ruby #
1
2
3
4
5
6
7
8
# > {:x => 4, :y => 7}.keys_sorted_by_value
# [:y, :x]
class Hash
  def keys_sorted_by_value
    to_a.sort_by {|tuple| rand - tuple.last.to_i}.map {|tuple| tuple.first}
  end
end