Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

If I have an array of hashes and I want to sort the array based on the (alphabetic) value of one of the hash keys, what's the nicest way to do it?

Replies are listed 'Best First'.
Re: sort array of hashes
by ikegami (Patriarch) on Oct 18, 2008 at 17:40 UTC
    @AoH = sort { $a->{key} cmp $b->{key} } @AoH;
      Super Search is your friend: How to sort by the key value of an Array of Hash structure?

      CountZero

      A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James