in reply to Re: Retrieving data with largest count
in thread Retrieving data with largest count

ikegami,
I know that it is unlikely in this situation that there would be negative or even nil counts, but this code does the wrong thing in the following situation:
ASDF 1 0 ASDF 1 -3
Specifically, it first sets the high water mark to 0 and then to -3. (Originally, I didn't have the group the same - corrected)

Cheers - L~R

Replies are listed 'Best First'.
Re^3: Retrieving data with largest count
by ikegami (Patriarch) on Jun 02, 2009 at 15:43 UTC
    No it doesn't??? In:
    1ct9B 3 1 1f7uA 2 3 1gaxA 2 1 1gpmA 3 5 1ihoA 6 4 1mopA 6 3 1ileA 2 5 1iq0A 2 3 1vlhB 5 3 1jhdA 5 4 ASDF 1 0 ASDF 1 -3

    Out:

    1ihoA 6 4 ASDF 1 0 1gpmA 3 5 1ileA 2 5 1jhdA 5 4

    0 >= -3, so next is executed, so the record for -3 is ignored. The item with the highest value for group 1 (ASDF 1 0) is printed.

      ikegami,
      You replied to yourself and not me I didn't see the response initially. I must be having a second Monday. I read the following code:
      next if $largest{$group_id} && $largest{$group_id}[2] >= $count;
      as
      next if $largest{$group_id}[2] && $largest{$group_id}[2] >= $count;
      Obviously not having a computer at home for a month and a trip to Vegas to boot has shrunk what little brain cells I have.

      Cheers - L~R

        You replied to yourself and not me (didn't see the response initially).

        No, I didn't...

        I must be having a second Monday.

        Indeed!