我有2D锯齿状阵列.我希望按行排序.
我搜索并找到了按列排序的代码
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]));
}
Run Code Online (Sandbox Code Playgroud)
我可以根据任何行调整它吗?
任何帮助表示赞赏.
我的锯齿状阵列样本(已添加)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
int n = 10;
int[][] capm = new int[3][];
for (int i = 0; i <= 2; i++)
{
capm[i] = new int[n + 1];
}
Random rand = new Random();
for (int i = 1; i <= n; …Run Code Online (Sandbox Code Playgroud)