in reply to Re: hash sorting/alphabetization issue : country postal codes
in thread hash sorting/alphabetization issue : country postal codes

my @sorted_keys = sort { $country_names{$a} cmp $country_names{$b} } k +eys %country_names;

Considering that in the end you would have sorted VALUES not the keys, above array variable name is rather misleading.

Correction. Afer grep's reply below, I saw that what was misleading was my claim made above. The array name was reasonable; it was my fault for forgetting that sort sorted the LIST based on result of BLOCK.

Replies are listed 'Best First'.
Re^3: hash sorting/alphabetization issue : country postal codes
by grep (Monsignor) on Jul 03, 2007 at 21:36 UTC
    Considering that in the end you would have sorted VALUES not the keys, above array variable name is rather misleading.

    I disagree - @sorted_keys contains SORTED KEYS, sorted by the values.
    But feel free to call it @keys_sorted_by_value if you feel like it.

      Oh! Right you were, and are. Indeed the array name is reasonable and the array does contain sorted keys not the values. I apologise for distrubing the peace.

      I will stand in a corner now for a while ...