On 1/29/2003 1:14 PM, Joseph P. Discenza wrote:
Andrew Mansfield wrote, on Wednesday, January 29, 2003 13:00
: I have a list of data read in from a text file in which each line has the
: following format:
: : time status type first_name last_name machine_name
: : where each value is separated by a space. I want to do a multi-sort by the
: various field types
: : for example: last_name then first_name then type then status then time.

You want to do a split, then sort on the pieces of the split. I suppose you
want to write back out the whole line?

Use the Schwartzian Transform (I got this from _Effective_Perl_Programming_,
Hall & Schwartz), which uses map to turn each data line into an anonymous
array, then sorts using the bits of the array, and finally map again to get
the original back:
There was a reference in the December issue of SysAdmin Magazine <http://www.samag.com> to a very informative paper on sorting <http://www.sysarch.com/perl/sort_paper.html> that you might find interesting.



_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Reply via email to