I have a list, winningCombos, of type class winningCombo, which has a class of type spin. Like so:
public List<winningCombo> winningCombos;
public class winningCombo
{
public List<spin> winningSymbols;
public double cumulativeValue;
}
public class spin
{
public string Name;
public double Value;
}
What is an efficient way to sort the list winningCombos in order by the value of the double cumaltiveValue within each class winningCombo? Some of these have the same value. So winningCombos[0] should be the smallest value of the double cumaltiveValue and work its way up. Thanks for any ideas!
This can be sorted in place via
List<T>.Sortlike so:You could also use LINQ to get back sorted results:
(Note the latter doesn’t change the original collection, but returns a new, sorted
IEnumerable<winningCombo>.)