Here's an interesting exercise for beginners. You have an array of strings, and you want to sort them but in a case-insensitive manner. You are doing this in two different places in your code. In one place, you write:

  # convert the strings to lowercase when comparing
  my @sorted = sort { lc($a) cmp lc($b) } @data;

And then later in your code, forgetting how you'd done it before, you use:

  # convert the strings to uppercase when comparing
  my @ordered = sort { uc($a) cmp uc($b) } @data;

But this gives you a headache:  the arrays AREN'T IDENTICAL.

The puzzle to you is to determine the reason and sample data that demonstrates the problem.

--
Jeff "japhy" Pinyan         %  How can we ever be the sold short or
RPI Acacia Brother #734     %  the cheated, we who for every service
http://japhy.perlmonk.org/  %  have long ago been overpaid?
http://www.perlmonks.org/   %    -- Meister Eckhart

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to