I have a class Tester
, where the definition is
public class Tester
{
public string Name;
public int TaskCount;
public Tester(string name, int taskCount)
{
Name = name;
TaskCount = taskCount;
}
}
, and I am asked to implement a method to sort a list of Tester
objects by the ascending order of TaskCount
.
For example, I have 3 Tester
objects in the list: new Tester("A", 1)
, new Tester("B", 5)
, new Tester("C", 1)
, and if I just use the default OrderBy
method to sort them by TaskCount
, the list would always looks like:
A (TaskCount: 1)
C (TaskCount: 1)
B (TaskCount: 5)
because in alphabetical order, the letter 'A' always comes before 'C'. Is there a way for me to sort the list in random alphabetical order while it's still in ascending order of TaskCount
, so there's 50% chance that the result would look like ACB
and 50% chance be CAB
? Thank you in advance!