0

Hi all, Clould someone please tell how to use the sorted function or equivalent to this function in Python 3 so that I can sort a dictionary. I cannot find any help on this.

Thanks for your time

Edited by FAITH2011: n/a

3
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by FAITH2011
1

You could be more specific, maybe this helps?

this_dict = {5:'ada', 3:'pascal', 4:'lisp', 1:'Python', 2:'Icon', 3:'Visual Basic'}
print('The programming languages in key order are:')
print(', '.join(repr(this_dict[key]) for key in sorted(this_dict)))

Edited by pyTony: n/a

0

mistake wrong posting

Edited by FAITH2011: wrong posting

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.