小编ste*_*reo的帖子

如何在C#中按行排序锯齿状数组?

我有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)

c# sorting row jagged-arrays

8
推荐指数
1
解决办法
2703
查看次数

标签 统计

c# ×1

jagged-arrays ×1

row ×1

sorting ×1