Date: Tue, 26 Jun 2001 15:40:08 GMT From: "Irfan Baig" Subject: how to sort array of similar hashes by one of the hash keys? Message-Id: <20010626.113916.1096689772.29810@irf.local> I've split data from a flatfile into hashes in an array, @game, all of which have keys 'name', 'score' and 'date'. @game = (); for ($i=0; $i<=$#scores; $i++){ ($game[$i]{'name'},$game[$i]{'score'},$game[$i]{'date'}) = split(/,/, $data[$i]); } I'm now trying to sort the array by comparing the values of the 'score' elements in each array's hash. Is this possible? I've tried some combinations such as: @sorted_game = sort{ $game[$a]{'score'} <=> $game[$b]{'score'} } @game; but no luck. Can someone help me out?