http://qs321.pair.com?node_id=767333


in reply to Re: What makes an array sorted and a hash unsorted?
in thread What makes an array sorted and a hash unsorted?

If you say values %hash to get the values of a hash, they will be in no particular order.

So if the following change was built into Perl, hashes would be considered sorted?

use subs qw( values ); sub values(\%) { my $h = shift; return keys(%$h) if !wantarray(); my @keys = sort keys(%$h); return @{$h}{@keys}; }
my %h = map { $_ => $_ } 'a'..'z'; print(values(%h), "\n"); # abcdefghijklmnopqrstuvwxyz

I think there's more to it than just this change in the builtin accessors.