0
counts = {'A1':3,'A2':2,'A3':1,'A4':10,'B1':11,'B2':12,'B3':3,'B4':0,'C1':3,'C2':16,'C3':8,'C4':2}
#Order grid
def orderGrid(grid):
lst = list()
for key,val in grid.items():
lst.append((val,key))
lst.sort(reverse=True)
for val,key in lst:
print key, val
#Order row
def orderRow(row):
count = dict()
for key in row.items():
if key[0] not in count:
count[key] = row[key]
else:
count[key] += row[key]
print 'A:', count
orderGrid関数は正常に実行できますが、orderrow関数はクラスタ用です。「A」から始まるすべての量、行をランク付け( 'A'、 'B'、 'C'、 'D')すべて同じ 'key [0]'を取得し、その値を辞書で計算する方法
は、ご希望の出力は何で、次のようになり交換しますか? – manvi77
@ manvi77のように、{A行:16、B行:26 ...} – hsbzzhz