Hi, 

> From: Laurent Colloud
> Sent: Monday, August 14, 2006 11:05 PM
> 
> Hi,
> 
> Here my - strange - problem.
> 
> To explain it, let's take the example of football. I 
> construct an array 
> of hashes of the results with team_id, total of pts, number of wins, 
> number of draws and number of defeats such as:
> [...]
> 
> puts "Team, Pts, W, D, L"
> myArray = myArray.sort { |a,b| b[:d] <=> a[:d]
> 		}.sort { |a,b| b[:w] <=> a[:w]
> 		}.sort { |a,b| b[:pts] <=> a[:pts]
> 		}.each do |row|
> puts "#{row[:team_id]}, #{row[:pts]}, #{row[:w]}, #{row[:d]}, 
> #{row[:l]}"
> end

try

myArray.sort {|a,b| 
  (b[:d] <=> a[:d]).nonzero? ||
  (b[:w] <=> a[:w]).nonzero? ||
  (b[:pts] <=> a[:pts])}

or (even better):

myArray.sort_by {|a| [a[:d], a[:w], a[:pts]]}

cheers

Simon