One benchmark


One benchmark

Tue, 15 October 2013 19:20

Ruby

Benchmark timings on 3000 iterations of sorting a 1000-element hash with random values

h.sort {|x,y| -(x[1]<=>y[1])} -- 16.7s
h.sort {|x,y| y[1] <=> x[1]} -- 12.3s
h.sort_by {|k,v| -v} -- 5.9s
h.sort_by {|k,v| v}.reverse -- 3.7