Re: [xsl] sorting by comparing two nodes

Subject: Re: [xsl] sorting by comparing two nodes
From: Ragulf Pickaxe <ragulf.pickaxe@xxxxxxxxx>
Date: Tue, 20 Dec 2005 09:27:51 +0100
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 :-)

Current Thread