in reply to Re: Sorting a Hash Ref
in thread Sorting a Hash Ref

my %sorted = ....

Everybody repeat after me: YOU CAN NOT SORT A HASH!

Hashes are unordered. Attempting to sort them just gets you a list which is stuffed back into a hash which has no internal order. You can get a sorted list of keys or values, but you can not sort a hash.

Replies are listed 'Best First'.
Re^3: Sorting a Hash Ref
by Juerd (Abbot) on Oct 26, 2005 at 20:34 UTC

    Everybody repeat after me: YOU CAN NOT SORT A HASH!

    Hm, okay... YOU CAN NOT SORT A HASH!

    Seriously, though, Tie::IxHash.

    Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }


    Perl 6 changes:

    • Ordered hashes will probably&hopefully be more accessible, and standard. This isn't certain yet.