I'm currently trying to sort a dictionary and I've resulted in sorting it as an array like this:
data = {"Craig" : 100, "Bravo" : 99, "Alpha" : 111}
sortlist = list(data.items())
for mx in range(len(sortlist)-1, -1, -1):
swapped = False
for i in range(mx):
if sortlist[i][1] < sortlist[i+1][1]:
sortlist[i], sortlist[i+1] = sortlist[i+1], sortlist[i]
swapped = True
if not swapped:
break
That returns [('Alpha', 111), ('Craig', 100), ('Bravo', 99)] i now need to be able to grab a value using a name, for instance Alpha would return 111. Does anybody know how to do this.
Thanks in advance