int[] numbers = { 3, 2, 1, 4, 5 }; Array.Sort(numbers); // Result: { 1, 2, 3, 4, 5 }
ListThe System Sort package library is included in the .NET Framework and can be accessed by importing the System namespace.names = new List { "John", "Alice", "Bob", "Lisa" }; names.Sort((x, y) => -1 * x.CompareTo(y)); // Result: { "Lisa", "John", "Bob", "Alice" }