Skip to content

Instantly share code, notes, and snippets.

@afbroman
Created August 20, 2012 21:59
Show Gist options
  • Save afbroman/3408312 to your computer and use it in GitHub Desktop.
Save afbroman/3408312 to your computer and use it in GitHub Desktop.
Ruby: sort by two array elements
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