Unsorter
Today’s generic lists support sorting calls that can be modified to sort ascending or descending. How about a sort method that will just mangle the data. It may have uses for your TDD (UnitTest) related work.
Here we go:
void Unsort() { Random rnd = new Random(); List<int> myList = new List<int>(); for (int i = 0; i < 100; i++) { myList.Add(i); } myList.Sort( delegate(int a, int b) { if (a != b) return rnd.Next(-1, 2); return 0; }); }
Now your list is unsorted.