Created
August 20, 2012 21:59
-
-
Save afbroman/3408312 to your computer and use it in GitHub Desktop.
Ruby: sort by two array elements
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
my_array.sort do |a, b| | |
comp = a[1].downcase <=> b[1].downcase | |
comp.zero? ? (a[2].downcase <=> b[2].downcase) : comp | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment