From: Paul Date: 2009-08-30T15:30:11+09:00 Subject: Sorting an array by multiple elements? Hi there, I have an array of arrays that I want to sort by multiple elements. Sample data in the array looks like: [ [ id, date, num, name ], [ id, date, num, name ], ... ] I need to sort by : (1) name, (2) date, and (3) id. I can sort by any one element in the array no problem using something like : > summary_data.sort! { |a,b| a[ 3 ] <=> b[ 3 ] } Unfortunately, I can't do this line more than once because it blows away any previous sorting. I found a few pages on the internet that describe how to "sort an array of Ruby objects by multiple class fields", however, I don't know how to create a "class field". I'm looking at an array, not a class. Is there a way to do this or do I need to convert my data to something else so I can do what I need? Please help. Thanks.