Lets say I have a dictionary:
dict1 = {'a': 3, 'b': 1.2, 'c': 1.6, 'd': 3.88, 'e': 0.72}
I need to be able to sort this by min and max value and call on them using this function I am still writing (note: 'occurences,' 'avg_scores' and 'std_dev' are all dictionaries and 'words' are the dictionary's keys.):
def sort(words, occurrences, avg_scores, std_dev):
'''sorts and prints the output'''
menu = menu_validate("You must choose one of the valid choices of 1, 2, 3, 4 \n Sort Options\n 1. Sort by Avg Ascending\n 2. Sort by Avg Descending\n 3. Sort by Std Deviation Ascending\n 4. Sort by Std Deviation Descending", 1, 4)
print ("{}{}{}{}\n{}".format("Word", "Occurence", "Avg. Score", "Std. Dev.", "="*51))
if menu == 1:
for i in range (len(word_list)):
print ("{}{}{}{}".format(cnt_list.sorted[i],)
I'm sure I am making this way more difficult on myself than necessary and any help would be appreciated. Thanks!