http://www.perlmonks.org?node_id=1152827


in reply to Re^3: Problem with a sort result
in thread Problem with a sort result

Looks to me like it's an integer/bigint problem: 9 digits:
perl -E' $h={foo=>{bar=>10000000000},baz=>{bar=>70000000},qux=>{bar=>2000000000 +0}}; say "$_: $h->{$_}->{bar}" for sort { eval { say $h->{$b}->{bar}. " - " +.$h->{$a}->{bar}." = ".($h->{$b}->{bar} - $h->{$a}->{bar}); $h->{$b}- +>{bar} - $h->{$a}->{bar} } } keys %$h; ' 10000000000 - 70000000 = 9930000000 20000000000 - 10000000000 = 10000000000 qux: 20000000000 foo: 10000000000 baz: 70000000
the expected output is correct. 12 digits:
perl -E' $h={foo=>{bar=>10000000000000},baz=>{bar=>70000000},qux=>{bar=>2000000 +0000000}}; say "$_: $h->{$_}->{bar}" for sort { eval { say $h->{$b}->{bar}. " - " +.$h->{$a}->{bar}." = ".($h->{$b}->{bar} - $h->{$a}->{bar}); $h->{$b}- +>{bar} - $h->{$a}->{bar} } } keys %$h; ' 20000000000000 - 70000000 = 19999930000000 10000000000000 - 70000000 = 9999930000000 foo: 10000000000000 baz: 70000000 qux: 20000000000000
incorrect ordering.

rdfield