Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个锯齿状数组,我需要按“2”列对其进行排序:
示例:数组[x][2]
我有大约 64 个“x”在哪里,在第二列(“2”在哪里)我有 4 个不同的选项,但我需要按第二个选项排序。
只需使用OrderBy:
OrderBy
array = array.OrderBy(inner => inner[2]).ToArray();
如果使用就地排序很重要,那么您可以使用Array.Sort:
Array.Sort
Array.Sort(array, (first, second) => string.Compare(first[2], second[2]));