RE: Random Sort
Hi, > I maintain a Web directory of fundraising software hosted on IIS > (www.tfraise.com/listings.aspx) and cannot figure how to get > my listings to > be rendered unsorted or, more to the point, sorted in a > random manner each > time the page is requested. I do not want to give > vendors/software with > names starting with the latter A a constant top ranking because of > alphabetical sorting, but give every vendor/software an equal > chance at > first user request. Is this really complicated to do? I had a > hard time > getting it to work as well as it is now. You can either use Dimitre's FXSL <http://www.topxml.com/xsl/articles/dice/> to generate the random sequence, or generate the random sequence outside XSLT processing and pass that in as a parameter. You can then use xsl:sort to sort the nodes based on the random sequence and position(), or you can write a recursive template that goes throught the sequence and processes a node in that position. If you don't know the number of vendors beforehand, you might want to first count them, then generate the random sequence of the corret size, and finally sort them. Cheers, Jarno - Hocico: Odio En El Alma
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