Sorting in dictonary and returning the result as an dictonary in python? -
suppose have dictonary
s={'a': 0, 'i': 0, 'm': 1, 'l': 0, 'q': 0, 'u': 0} i need sort out value , result should dictonary , output of sorting should result as
s={'a': 0, 'q': 0, 'u': 0, 'i': 0, 'm': 1, 'l': 1}
how can ?
a standard dictionary cannot sorted, may want use list of tuples if not using dictionary indexing or use ordereddict, remember order in items added.
Comments
Post a Comment