Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
Comparing how to do a reverse sort
require 'fruity'
a = (1..100).to_a.shuffle
compare do
sort { a.sort{|x, y| y <=> x} }
sort_by { a.sort_by{|x| -x} }
reverse { a.sort.reverse }
reverse! { a.sort.reverse! }
# reverse! is faster than reverse by 10% ± 1.0%
# reverse is faster than sort_by by 6x ± 0.1
# sort_by is faster than sort by 60% ± 1.0%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.