Array.Sort also provides Predicate-Overload. Here you can specify your sorting behavior:
Array.Sort(myArray, (p, q) => p[0].CompareTo(q[0]));
You can also use LINQ to sort the array:
string[] myArray = ...; string[] sorted = myArray.OrderBy(o => o).ToArray();
LINQ also allows you to sort a 2D array:
string[,] myArray = ...; string[,] sorted = myArray.OrderBy(o => o[ROWINDEX]).ThenBy(t => t[ROWINDEX]).ToArray();
By default, LINQ sorting behavior is also performed alphabetically. You can undo this by using OrderByDescending () / ThenByDescending () instead.
0xDEADBEEF
source share