Fasterer: Enumerable#sort is slower

Enumerable#sort is slower than Enumerable#sort_by
This commit is contained in:
Reinier Balt 2015-08-19 15:19:47 +02:00
parent 5092b388fe
commit 405ad5a79f
2 changed files with 2 additions and 2 deletions

View file

@ -22,7 +22,7 @@ module Stats
def find_top10_longest_running_projects
projects = user.projects.order('created_at ASC')
projects.sort{|a,b| b.running_time <=> a.running_time}.take(10)
projects.sort_by{ |p| p.running_time }.take(10)
end
end