我读了很多关于对2D数组进行排序的帖子,但我仍然无法掌握它,所以我想知道是否有人能给我一些建议...
我有一个列表字母和数量的数组(我正在对一段文本进行频率分析)。我已经将这些数据读入矩形数组中,并需要按最高频率的顺序进行排序。以下是我的代码:
//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++;
}