Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

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])); 
} 
Comment

PREVIOUS NEXT
Code Example
Csharp :: unity read from text file 
Csharp :: best practice c# check if string is null or whitespace 
Csharp :: how to check if string can be converted to int c# 
Csharp :: how to run c# code in visual studio code terminal 
Csharp :: c# keyboard enter 
Csharp :: c# paste from clipboard 
Csharp :: includes method C# 
Csharp :: c# string to enum conversion 
Csharp :: debug.log unity 
Csharp :: rigidbody.addtorque 
Csharp :: c# check if array is empty 
Csharp :: c# read file from path 
Csharp :: take screenshot in c# 
Csharp :: access a local varible in a different function C# 
Csharp :: perlin noise unity 
Csharp :: reverse for loop 
Csharp :: c# random generator 
Csharp :: Compare trees 
Csharp :: c# list index 
Csharp :: update models with ef core 
Csharp :: WebClient c# with custom user agent 
Csharp :: weighted random c# 
Csharp :: merge sort in c# 
Csharp :: c# write byte[] to stream 
Csharp :: convert array object to int[] c# 
Csharp :: c# console foreground color 
Csharp :: c# search string array 
Csharp :: c# array to list 
Csharp :: c# find element by condition 
Csharp :: c# string replace comma with newline 
ADD CONTENT
Topic
Content
Source link
Name
5+6 =