Re: List Sort
jon klein <[email protected]>
| Newsgroups | gmane.comp.breve |
|---|---|
| Message-ID | <[email protected]> |
On Feb 1, 2004, at 9:48 AM, Will Davis wrote: > Hi all, > > I'm trying to sort a list of vectors using the sort list with > method-name operator, and can't really understand the syntax. Does the > sort command have arguments? How are you meant to specify the sorting > method (method-name) - can it have arguments? If not, how do you get > the data to sort the list in the first place? Basically, my algorithm > takes two vector arguments and compares the vector components and > sorts so that -x goes before +x, then by y and then by z, so that the > list ends up sorted from (-x,-y,-z) to (x,y,z). > > Any help on this would be greatly appreciated. Take a look at the "Walker" demo -- the genomes there are sorted by distance: sort seats with compare-distance. The "compare-distance" method looks like this: + to compare-distance of a (object) with b (object): result (float). result = (b get-distance) - (a get-distance). return result. Your compare distance will take vectors, do some calculation, and return a value indicating which of the vectors should come first in the sorted list. - jon klein _______________________________________________ breve mailing list [email protected] http://www.spiderland.org/mailman/listinfo/breve