[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] How to Do Random "Shuffle"?
Using XSLT 2 I need to implement rendering of "match table" questions where you have two sets of items, the match item and the thing it matches to. I want to present this as a literal table, where the first column is the match-from items in source order and the second column is the match-to items, in random order. I think this is best characterized as a "shuffle" problem, where you want to reorder a list randomly but all items in the list must be accounted for. I can think of a recursive algorithm: given a list, generate a random integer between 1 and the list length, select that item and add it to the result list, then call this function on the original list minus the node you just selected. Is there an easier or more efficient way to do it? Thanks, Eliot bbbbb Eliot Kimber, Owner Contrext, LLC http://contrext.com
|
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
|