I have a dictionary with string keys and int values
for word in coocc[query]:
resp[word]=coocc[query][word]
{"share": 1, "pizza": 3, "eating": 1,...}
I need to sort by value and return a json string.
The following works:
sortedList=sorted(resp.items(), key=operator.itemgetter(1), reverse=True)
sortedDict=collections.OrderedDict(sortedList)
return json.dumps(sortedDict)
'{"cheese": 4, "pizza": 3, "table": 3,..}
but it doesn't seems very efficient to me