0

I have a list which contains SelectListItem, I am making dropdownList for it. This is my list element's

1 Declined
2 Bad Phone
3 Medical
4 No Answer
5 Try Again
6 Left Voice mail
7 Skip 
8 Not Valid
9 Warning
10 Unemployed

The list is sorting according to their values(I have shown values next to the item) I have to display elements like this

5 Try Again
7 Skip 
6 Left Voice mail
3 Medical
8 Not Valid
1 Declined
2 Bad Phone
4 No Answer
9 Warning
10 Unemployed

ie in Random Order, How can I do this Random sorting in List, One thing I can do is to find index of each item and change its index/position,but it will be a hectic. The List items are fixed and are not dynamic.

Syed Salman Raza Zaidi
  • 2,172
  • 9
  • 42
  • 87

1 Answers1

2

you can use Guid.NewGuid().ToString() to randomly sort the order, eg.

var lstResult = yourList.OrderBy(x => Guid.NewGuid().ToString()).ToList();
John Woo
  • 258,903
  • 69
  • 498
  • 492