From: Brett Williams Date: 2002-09-11T03:35:02+09:00 Subject: Multi-level sort idiom? Let's say I have an array, each element of which is a 2-dimensional array of ints. I want to sort with the first element in the 2D array taking precedence, but using the second as a tiebreaker. So far, I haven't come up with a nice idiom that doesn't seem a bit kludgy: What I tried was to do something like: x.sort {|a,b| a[0]<=>b[0] || a[1]<=>b[1]} but 0 is not false in Ruby so this doesn't work. x.sort {|a,b| 2*(a[0]<=>b[0]) + (a[1]<=>b[1])} works, but is non-intuitive and not pretty. Does anyone have a nice clean rubyesque idiom for this?