Created
July 18, 2014 14:11
-
-
Save coleww/55cea96ff08dd30af611 to your computer and use it in GitHub Desktop.
weighted shuffle in ruby.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
things.sort_by do |thing| | |
-((thing.created_at.to_f / Time.now.to_f) * rand) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
for when the client wants results sorted randomly AND by most recent >_<