I think I understand what you want to do. You have a different frequency order than words. To do this, you need to sort twice:
from operator import itemgetter word_list = [('this', 4), ('in', 4), ('dedicated', 4), ('who', 3), ('us', 3), ('they', 3), ('so', 3), ('shall', 3), ('people', 3), ('is', 3), ('great', 3), ('dead', 3), ('are', 3), ('It', 3), ('which', 2), ('what', 2)]
Result:
[('dedicated', 4), ('in', 4), ('this', 4), ('are', 3), ('dead', 3), ('great', 3), ('is', 3), ('It', 3), ('people', 3), ('shall', 3), ('so', 3), ('they', 3), ('us', 3), ('who', 3), ('what', 2), ('which', 2)]
This is the so-called complex view. More details here . And this works because the sort operations in python are stable. It means that:
when several records have the same key, their original order is saved.