Skip to content

Instantly share code, notes, and snippets.

@akdubya
Created December 30, 2009 23:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akdubya/266484 to your computer and use it in GitHub Desktop.
Save akdubya/266484 to your computer and use it in GitHub Desktop.
MyStruct = Struct.new :name, :rating
a = MyStruct.new 'Michael', 10
b = MyStruct.new 'Jim', 9
c = MyStruct.new 'Dwight', 10
arr = [a, b, c]
arr.sort_by {|obj| [-obj.rating, obj.name]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment