Skip to content

Instantly share code, notes, and snippets.

@goshki
Created December 30, 2015 07:20
Show Gist options
  • Save goshki/69f3ee4e52d65a8af241 to your computer and use it in GitHub Desktop.
Save goshki/69f3ee4e52d65a8af241 to your computer and use it in GitHub Desktop.
A helper method to easily randomize the order of elements in a given list using LINQ.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
public class LinqListShuffler {
public List<string> Shuffle(List<string> list) {
Random random = new Random();
return list.OrderBy(x => random.Next()).ToList();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment