Terje Tjervaag <flecktone / gmail.com> wrote:
> 
> Say you have an array of these music tracks:
> Track = Struct.new("Track", :name, :artist, :album, :track_number)
> 
> .and you want to sort the array first by artist, then by album within
> that artist and finally by track number within the album, this can
> still be done by a pretty neat sort block:

tracklist.sort_by {|i| [i.artist, i.album, i.track_number] }

works because ruby already defines Array#<=> to check the first entry,
break ties on the second entry, etc.

martin