[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: sorting product descriptions
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|