in reply to Schwartzian transform for randomizing a list

Hehe, that'll work.

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).


Mike
  • Comment on Re: Schwartzian transform for randomizing a list