-2

Possible Duplicate:
Randomize a List<T> in C#

i have two lists like below :

List<strig> LS1 = new List<string>();
List<strig> LS1 = new List<string>();  

LS1 have 5000 items inside.
LS2 is empty.
LS1 is a sorted list Ascending.
now i want to an shuffle list(created from LS1) and add that list to LS2!(totally shuffle)
what is the best way for doing that?

Community
  • 1
  • 1
SilverLight
  • 19,668
  • 65
  • 192
  • 300

1 Answers1

2
Random rnd = new Random();
var LS2 = LS1.OrderBy(_ => rnd.Next()).ToList();

But better use this Fisher-Yates shuffle

Community
  • 1
  • 1
L.B
  • 114,136
  • 19
  • 178
  • 224