我有名單的數組:獲取列表idexes的數組列表與的greates elementrs計數C#
例如:
Graph[0] = new List<int>() { 1, 2 };
Graph[1] = new List<int>() { 0 };
Graph[2] = new List<int>() { 0, 1, 3, 4 };
Graph[3] = new List<int>() { 2, 4, 1 };
Graph[4] = new List<int>() { 2, 3 };
Graph[0].Count // give 2
Graph[1].Count // give 1
Graph[2].Count // give 4
Graph[3].Count // give 3
Graph[4].Count // give 2
我想獲得一個數組(或列表),其中包括按每個列表中元素的數量排序的列表的索引。因此,對於此示例,它將是:
orderList[0] -> 2 //(because Graph[2].Count give 4)
orderList[1] -> 3 //(because Graph[3].Count give 3)
orderList[2] -> 0 //(because Graph[0].Count give = 2)
orderList[3] -> 4 //(because Graph[4].Count give = 2)
orderList[4] -> 1 //(because Graph[1].Count give = 1)
orderList是一個n元素數組。
你能澄清嗎? – Greg 2015-02-06 22:42:11
你想排序清單嗎?從最高到最低? – TheUknown 2015-02-06 22:43:03
好吧給你好! – mybirthname 2015-02-06 22:49:18