Вопрос

I have a jagged array and I need to sort it by the column "2":

example: array[x][2]

What I have is about 64 where the "x" is and in the second column (where the "2" is) I have 4 different options, but I need to sort by the second option.

Это было полезно?

Решение

Just use OrderBy:

array = array.OrderBy(inner => inner[2]).ToArray();

If it's important to use an in place sort then you can use Array.Sort:

Array.Sort(array, (first, second) => 
    string.Compare(first[2], second[2]));
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top