小编L1a*_*m22的帖子

如何在C#中对2D数组进行排序

我已经阅读了很多关于排序2D数组的帖子,但我仍然无法掌握它,所以我想知道是否有人可以给我一些建议......

我有一个列出字母和数量的aray(我正在对一段文字进行频率分析).我已将这些数据读入矩形数组,需要先按最高频率对其进行排序.到目前为止,这是我的代码:

    //create 2D array to contain ascii code and quantities
    int[,] letterFrequency = new int[26, 2];

    //fill in 2D array with ascaii code and quantities
    while (asciiNo <= 90)
     {

       while ((encryptedText.Length - 1) > counter)
      {
                if (asciiNo == (int)encryptedText[index])
               {
                      letterCount++;
               }
                counter++;
                index++;
      }

    letterFrequency[(storeCount), (0)] = (char)(storeCount+66);
    letterFrequency[(storeCount), (1)] = letterCount;
    storeCount++;
    counter=0;
    index=0;
    letterCount = 0;
    asciiNo++;
    }
Run Code Online (Sandbox Code Playgroud)

c# arrays sorting

3
推荐指数
1
解决办法
2万
查看次数

标签 统计

arrays ×1

c# ×1

sorting ×1