Im trying to sort a dictionary by the values, and i saw this post : Sort a Python dictionary by value
i need to get only the key that have the bigger values in a list,and not in tuple so I wrote this (which look a bit clumsy). BUT if 2 keys had the same value i need to sort them in alphabet way.
this is what i tried to do :
import operator
final_sort=[]
sorted_x = sorted(x.items(), key=operator.itemgetter(1))
for item in sorted_x[::-1]:
final_sort.append(item[0])
but this is good only for the numbers values condition.
for example :
inp : x = {'a': 2, 'b': 4, 'c': 6, 'd': 6, 'e': 0}
out : ['c', 'd', 'b', 'a', 'e']