This question is a part of my current problem, so let's start with the big picture.
I am trying to sort a dictionary by the values in descending order. My dictionary is 1-to-1 corresponding, such as:
('ID1':value1, 'ID2':value2, ......)
I followed this thread and find my answer:
import operator
sorted_dict = sorted(original_dict.iteritems(), key = operator.itemgetter(1), reverse = True)
Then I tried to extract the keys in sorted_dict since I thought it is a dictionary. However, it turns out that sorted_dict is a list, thus has no keys() method.
In fact, the sorted_dict is organized as:
[('ID1', value1), ('ID2', value2), .....] # a list composed of tuples
But what I need is a list of ids such as:
['ID1', 'ID2', ......]
So now, the problem turns to How to extract variable in specific position for each of the tuples in a list?
Any suggestions? Thanks.
 
     
     
     
    