I'm sorting dictionary with float values to ascending order. Here's my code
dicdata = {'mike': 15.12, 'jenny': 2.53, 'glenn' : 5.16, 'Meo': 1.01}
sorted_dicdata = sorted(dicdata.items(), key=operator.itemgetter(1), reverse=True)
The output is not accurate. it gives me glenn:5.16 mike:15.12 jenny:2.53 meo:1.01 How can i fix this?
floatvalues - not to be confused withdecimal.Decimalvaluesglenn:5.16 mike:15.12 jenny:2.53 meo:1.01- that looks very much like you've copy and pasted an attempt at converting it back to adict- rather than a list of 2-tuples whichsortedwhich return in this case. Can't help but feel you haven't posted your full code here...