[Solved] How to sort a list of int list


You can do this

var results = numberLists.OrderBy(x => x[0])
                         .ThenBy(x => x[1])
                         .ThenBy(x => x[2]);

foreach (var result in results)
{
   foreach (var subresult in result)
   {
      Console.Write(subresult + " ");
   }
   Console.WriteLine();
}

Output

2 3 9
2 4 7
4 7 8
6 8 9

Full Demo here


Additional Results

Enumerable.OrderBy Method (IEnumerable, Func)

Sorts the elements of a sequence in ascending order according to a
key.

Enumerable.ThenBy Method (IOrderedEnumerable, Func)

Performs a subsequent ordering of the elements in a sequence in
ascending order according to a key.

4

solved How to sort a list of int list