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

Re: [FWP] Sort challenge



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>;

-- 
John Porter


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