Browse Source

replace sort with sort_by

this is more idiomatic and generally faster
gabriele renzi 11 years ago
parent
commit
c287d8ae84
1 changed files with 1 additions and 1 deletions
  1. 1 1
      rails/app/controllers/hello_world_controller.rb

+ 1 - 1
rails/app/controllers/hello_world_controller.rb

@@ -18,7 +18,7 @@ class HelloWorldController < ApplicationController
   def fortune
     @fortunes = Fortune.all
     @fortunes << Fortune.new(:message => "Additional fortune added at request time.")
-    @fortunes = @fortunes.sort { |x, y| x.message <=> y.message }
+    @fortunes = @fortunes.sort_by { |x| x.message }
   end
 
   def update