xsl-list
[Top] [All Lists]

Re: sorting by comparing two nodes

2005-12-20 01:27:51
Hi again,

I am not all that clear on how you would sort these.

I try to implement a Graham scan to compute the convex hull of the
points.

expr:= sqrt((x-$ref/x)^2+(y-$ref/y)^2)

thanks for your idea. but your expr just takes one point and the reference
point as the sorting key. my sorting key changes each time another pair of
points is compared.

Okay, I really do not understand this.
Don't you just want the vectors sorted according to distance from the
reference point? In what way do they change?

Given you example, what output would you want?

<Snip/>
I know I can't access the predecessor in a xsl:sort. But is there another
way to implement this? Well in the end it is just a normal quicksort with
a function which compares two elements and returns -1 or 0 or 1 to determine
the way of sorting.

It still seems to me that you want a normal sorting. Your thinking is
just of the procedural kind, where you have to do the coding yourself.
In XSLT you just pass the comparison expression, and the XSLT engine
will itself do the sorting on all the elements in the nodeset applied.

Regards,
Ragulf Pickaxe :-)

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--