You might want to look at Fisher-Yates theory for the theory behind a slightly "better" way to do it, but I'm sure your answer did the job well enough for what you needed.
F-Y is going to be a lot better if you have to do a lot of shuffles, or if you're shuffling large lists, though. It's cheaper than a sort (O(n) vs O(n lg n), I believe).
In reply to Re: Schwartzian transform for randomizing a list
by RMGir
in thread Schwartzian transform for randomizing a list
by fokat
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |