Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

2
  • There's no need to create two lists - you can just swap elements in the list in a shuffle style way. This needs to be done with a bit of care, but it's better (IMO) than creating another copy for no reason. Commented Mar 17, 2009 at 17:14
  • You can, but it would make code less readable. IMHO this way is better, because it's more clear. Remember that we operate mainly on references, not values so there isn't much memory cost except for the list itself. Commented Mar 18, 2009 at 17:32