[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] Sort challenge



Rick Klement wrote:
> 
> 
> This seems way too long...
> 
> #!/usr/bin/perl
> print sort{lc$a cmp lc$b}map/\|(.+)\|(.+)/&&"$1, $2\n"||
> /.*\|(.+)\||.*\|\|(.+)|(.+)\|\|/&&"$1$2$3\n",<DATA>
> 

Getting better:

print sort{lc$a cmp lc$b}map{
s/(.*)\|(.*)\|(.*)/$2?$3?"$2, $3":$2:$3||$1/e;$_}<DATA>

-- 
Rick Klement

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe