public class MyClass
{
public int X { get; }
public int GetSomeValue(List<MyClass> values)
{
return valueOfOperation;
}
}
Let's say I have a List<MyClass>. I want to sort it by property X. If there are multiple objects with same value of X, I want to sort those by GetSomeValue(objectsWithSameXValue) which returns a value of some operation. Said return value is calculated using all objects with equal value of X.
Desired result should look like this:
Object Property X GetSomeValue({item2, item3, item4})
item1 1
item2 3 2
item3 3 3
item4 3 9
item5 4
Everything is sorted by X. Item2, item3 and item4 are also sorted by GetSomeValue().
Is there anything I can do without huge if...else trees? I tried different approaches, but sooner or later I got lost because it became confusing.