Hello, I'm sorting my integers with .Sort function with list but I want to compare other value if my integers is equal. How can I make it? Thank you.
Assuming you're sorting a list of things that contain an int value and the other value you want to compare, you can use the sort version that takes a custom comparer. Example to sort by id, and if the ids are the same, it will then compare the score. Code (CSharp): public struct MyStruct { public int id; public int score; } ListOfMyStructs.Sort( (MyStruct x, MyStruct y) => { var idResult = x.id.CompareTo(y.id); if (idResult != 0) return idResult; else return x.score.CompareTo(y.score); } ); My example was typed up outside of the IDE so may contain typos.