I connected to mysql database and fetched two columns from mysql with python with
query = ('select test_id, a_id from b.atc_id_TO_cID ')
cursor.execute(query)
rows = cursor.fetchall()
CountinmyDi = {}
for row in rows:
if not row[0] in CountinmyDi.keys():
CountinmyDi[row[0]] = 1
else :
CountinmyDi[row[0]] += 1
for key in CountinmyDi.keys():
print str(key) + ":" ,CountinmyDi[key]
and created a dictionary CountinmyDi to count the unique items inside the dictionary. Now i have for example :
testA : 2 testB : 82 testC:102 test D : 3 test E:1 and so on .. about 220 items
I want to sort the items inside my dictionary for example increasing to decreasing order based upon their values for instance testC : 102, testB : 82 , testD :3 , test A :2 , test E : 1. I would like to get an idea how i could do that . Thank you and if you need further infos, i could gladly provide.