 |
GeneralStonewall Magician
Joined: 02 Feb 2004 Posts: 364 Location: USA
|
|
|
|
 |
charneus Wizard

Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Sat Jun 12, 2010 2:40 pm |
| Code: |
#LOCAL $RSort $NItem
#LOOP %numitems(@variable) {$NItem=%item(@variable, %random(1,%numitems(@variable));#ADDITEM $RSort $NItem;#DELITEM variable $NItem}
variable=$RSort |
That should be a workable workaround if this never gets implemented. :P
Charneus |
|
|
|
 |
ralgith Sorcerer
Joined: 13 Jan 2006 Posts: 715
|
Posted: Sat Jun 12, 2010 10:20 pm |
I did this a much different way in zMUD... ;)
| Code: |
#WHILE (%numitems(@UnSorted) > 0) {
#VAR rand %random(1, %numitems(@UnSorted))
#VAR Sorted %additem(%item(@UnSorted, @rand), @SortedList)
#VAR UnSorted %delnitem(@UnSorted, @rand)
} |
|
|
_________________
CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate |
|
|
 |
Zugg MASTER

Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Mon Jun 14, 2010 4:51 pm |
Random sorting is tricky even using the new Json table custom sorting method. With the internal custom sorting, you create your own Compare routine that takes two string values and returns -1 if stringAstringB. This needs to be a consistent function that always returns the same value for a given pair of strings. A Random sort won't work with this kind of custom sorting architecture.
So, using the above suggestions to resort your list randomly when you want it will be what you need to use.
However, I need to ask why you need the actual list itself randomly sorted. Can't you just use the %random function to generate a random index value whenever you need to access something in your list? |
|
|
|
 |
|
|
|