>>>>> "Dan" == Dan Brian <[EMAIL PROTECTED]> writes:

Dan> IMO the very quest for a name would be reason enough to not do it.
Dan> "map_sort_map"? That begs the question. And since Randal asks that it not
Dan> be named after him ... (I heard he filed a trademark on Schwartzian, so
Dan> that's out. :)

It's just that it means nothing, except to those who probably already
know how to open-code the map-sort-map.  So there's no gain.  Maybe we
could just teach sort how to do this neater, so there's no new
operator.  Like maybe

   sort { $a/$b expression } { transforming expression, glued with $_ } @list

so $a->[0] is guaranteed to be the original element, and the list-return
value of the second block becomes $a->[1]... $a->[$#$a].

So, to sort case insensitive (bad example :):

@sorted = sort { $a->[1] cmp $b->[1] } { uc } @list;

or to sort on GCOS and then username of password lines:

@sorted = sort { $a->[5] cmp $b->[5] or $a->[1] cmp $b->[1] }
          { split /:/ } `cat /etc/passwd`;

That captures the canonical ST pretty well, where $a->[0] is always
the original element.

Maybe we can call this operator "schwart". :)

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[EMAIL PROTECTED]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

Reply via email to