[LUNI] Sorting algorithm in perl?
Steven Lembark
lembark at wrkhors.com
Fri Mar 22 23:45:08 CST 2002
> anArray.sort(lambda x,y: cmp(x[0],y[0]) or cmp(x[1],y[1]))
Trick is to use anonymous structures for it in Perl (basically
the same technique you'd use in Lisp(where Randal got the basic
idea for the Schwartzian Transform(which is really just tacking
on a car for the sort and taking a cdr off the end when you're
done)(sort of))).
Main problem with the technique above is that you have to
hard-code the offsets. With a list based technique you can
pass in a list of sort offsets and deal with the entire
thing dynamically (see previous posting).
--
Steven Lembark 2930 W. Palmer
Workhorse Computing Chicago, IL 60647
+1 800 762 1582
More information about the luni
mailing list