On Oct 3, JupiterHost.Net said:

I have a list of strings that start with an uppercase B, Q, or Z

I need to sort them so they are in order of Q, B , then Z

Any ideas or input on how to efficiently do that with sort() or even map() is most appreciated :) perldoc -f sort|-f map didn't appear to address this situation :(

I would use map() before and after sort() to "correct" leading characters.

  my @sorted =
    map { tr/123/QBZ/; $_ }
    sort
    map { tr/QBZ/123/; $_ }
    @data;

--
Jeff "japhy" Pinyan        %  How can we ever be the sold short or
RPI Acacia Brother #734    %  the cheated, we who for every service
http://www.perlmonks.org/  %  have long ago been overpaid?
http://princeton.pm.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