Date: Wed, 27 Jun 2001 08:13:01 GMT From: Bart Lateur Subject: Re: how to sort array of similar hashes by one of the hash keys? Message-Id: Irfan Baig wrote: >@sorted_game = sort{ $game[$a]{'score'} <=> $game[$b]{'score'} } @game; You're mixing two concepts. Or, you select an item by index, but then you need to feed the indexes to the sort function (and getting a list of indexes out), or you must assume that $a and $b are the $game[$i] items, thus, hash references. So: @sorted_index = sort{ $game[$a]{'score'} <=> $game[$b]{'score'}} 0 .. $#game; @sorted_game = @game[@sorted_index]; or @sorted_game = sort{ $a->{'score'} <=> $b{'score'} } @game; -- Bart.