[San-Diego-pm] Sort problem
Christopher Hart
christopher.p.hart at gmail.com
Mon Aug 30 20:53:00 PDT 2010
"Untested, but I usually get this stuff mostly right. :)"
I LOL'ed when I read this from the man who taught most of us perl.
:)
On Mon, Aug 30, 2010 at 7:39 PM, Randal L. Schwartz
<merlyn at stonehenge.com>wrote:
> >>>>> "Joel" == Joel Fentin <joel at fentin.com> writes:
>
> Joel> I've tried everything I can think of without success.
> Joel> my @A = ('aaa10.jpg','aaa9.jpg','bbb9.jpg','bbb10.jpg');
>
> Joel> The desired order:
> Joel> aaa9.jpg
> Joel> aaa10.jpg
> Joel> bbb9.jpg
> Joel> bbb10.jpg
>
> Joel> Sorted first by the text. Those with the same text sorted
> Joel> numerically.
>
> my @sorted =
> map $_->[0],
> sort { $a->[1] cmp $b->[1] or $a->[2] <=> $b->[2] }
> map [$_, /^(\D+)(\d+)/],
> @input;
>
> Untested, but I usually get this stuff mostly right. :)
>
> --
> Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
> <merlyn at stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
> Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
> See http://methodsandmessages.vox.com/ for Smalltalk and Seaside
> discussion
> _______________________________________________
> San-Diego-pm mailing list
> San-Diego-pm at pm.org
> http://mail.pm.org/mailman/listinfo/san-diego-pm
>
--
Respectfully,
Chris Hart
Developer / System Administrator
Insuremonkey.com
2080 E. Flamingo, Suite 223
Las Vegas, NV 89119
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/san-diego-pm/attachments/20100830/98849aa5/attachment.html>
More information about the San-Diego-pm
mailing list