Answers for "c# 2-dimensional array sort"

C#
2

c# 2-dimensional array sort

static void Main()
{  // could just as easily be string...
    int[][] data = new int[][] { 
        new int[] {1,2,3}, 
        new int[] {2,3,4}, 
        new int[] {2,4,1} 
    }; 
    Sort<int>(data, 2); 
} 
private static void Sort<T>(T[][] data, int col) 
{ 
    Comparer<T> comparer = Comparer<T>.Default;
    Array.Sort<T[]>(data, (x,y) => comparer.Compare(x[col],y[col])); 
}
Posted by: Guest on April-23-2021

Code answers related to "c# 2-dimensional array sort"

C# Answers by Framework

Browse Popular Code Answers by Language