in reply to Re: Comparing all keys in a hash
in thread Comparing all keys in a hash
Of course I know you're not suppose to rely on hash order but would two hashes with the same keys return in the same order? I would think so but don't know (And don't have time to test) but if it did you could skip the sort. But it probably would be a bad idea.In the current Perl 5 implementation of hashes, you cannot rely of ordering of keys. You may get two canonically identical hashes, which should appear the same, but compare differently without a sort. If the elements were inserted in different sequences, you can see this.
Try comparing { foo => 1, bar => 5 } with { bar => 5 , foo => 1 }.
See also this thread
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Comparing all keys in a hash
by shotgunefx (Parson) on Mar 20, 2003 at 19:14 UTC |