in reply to Numeric Sorting on Characters

This is not an error, it is a warning. You can:
  1. Ignore it.
  2. Turn off this warning. Insert no warnings 'numeric'; into the sort code.
    sub by_cpu { no warnings 'numeric'; $passes->{$a}{cpu} <=> $passes->{$b}{cpu}; } for my $tc (sort by_cpu keys %$passes) { # ...
  3. Filter out the non-numeric values:
    my @dashed; my @sorted = sort { $passes->{$a}{cpu} <=> $passes->{$b}{cpu} } grep { '-' ne $passes->{$_}{cpu} or push @dashed, $_ and 0 } keys %$passes; for my $tc (@dashed, @sorted) { # ...

Update: Ouch. no cannot go to the sort code. Changed option 2 and added option 3.

لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^2: Numeric Sorting on Characters
by halecommarachel (Sexton) on Aug 15, 2013 at 00:08 UTC

    Hi choroba,
    Can you explain what is happening when @sorted is generated? I'm not sure how you were able to grep after sort. I do understand that the grep checks if the value equals "-", otherwise is pushes it to @dashed, but why "and 0"?
    Thanks!

      When functions are chained, they are called from right to left. So, that's what happens: Keys are taken. For each key, if it is not a dash, it is left in the list that is later sorted. If it is a dash, it is pushed to @dashed and 0 is returned so grep removes it from the list to be sorted.
      لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ