Subject: Re: [xsl] sorting product descriptions From: Francis Norton <francis@xxxxxxxxxxx> Date: Fri, 27 Apr 2001 23:12:09 +0100 |
Tobi, you owe me a beer. You have a solution at http://redrice.com/xml/sortfunction.zip It's reasonably well-structured, with separate sort and comparison templates, so that it could be used for other comparison requirements or with alternative sort algorithms. There are two interesting problems that have to be cracked, and I'm not conviced that I've come with the best solution to either. The first is that it's difficult to implement my favorite sort algorithm (split down to pairs, then do ordered mereges all the way back up again) without any ordered assignable data structures in the language. The best one I could come up with that didn't need this was to pick the highest on each pass through the unsorted node-set, emit it, then recurse through the remainder of the node-set. Obviously you could pick the highest and lowest on each pass, and reduce the number of passes by about half, but I'd be interested if there was a substantially better solution. The second problem is that XSLT doesn't really have a simple operator for doing string comparisons, so I ended up cheating and using xsl:sort inside an otherwise unnecessary xsl:for-each. Again, it may well be possible to improve on this, perhaps using string functions over variables containing ordered alphabets. Francis. XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] sorting product descripti, Tobias Reif | Thread | Re: [xsl] sorting product descripti, Tobias Reif |
[xsl] xsl/xsql, Kevin_Gutch | Date | Re: [xsl] xsl/xsql, Steve Muench |
Month |