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

Re: [FWP] Sort challenge



At 11:32 AM 2/21/01 -0500, John Porter wrote:
>Lou Hevly wrote:
> > __DATA__
> > ae|Evans|Anne
> > le|Evans|Louise
> > he|Evans|Helen
> > je|Evans|
> > pete||Peter
> > xs|Sanchez|
> > rwj||
> > est||
> >
> > 1) If there's a last name, the program should sort first by that and 
> then by the firstname (if there is one);
> > 2) If no last name, then sort by first name;
> > 3) If neither last nor first name, then sort by username
>
>   map { $_[1] }
>   sort { $a->[0] cmp $b->[0] }
>   map { [ join( '', reverse split /\|/ ), $_ ] }
>   <DATA>;

Eh?  That first line should be $_->[1], and even then it doesn't give the 
right results; poster specified output should be "Last, First", "Last:, 
"First", or "username" depending on what was present, sorting should be 
lowercase, and output should be sorted differently.

--
Peter Scott
Pacific Systems Design Technologies


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