Newbie problem

F. GEIGER fgeiger at datec.at
Tue Dec 17 07:33:47 EST 2002


That works the same way as with keys:

values = dict.values()
values.sort()

You can supply here a compare function so that sort can work in a more
specific way.

If the dict should always be sorted, you could use a list for the values and
a dic for the indices.

Dicts are unsorted by their nature. Having the keys sorted means to be able
to access the values in a sorted way. So, perhaps you could be more specific
about your goals?

Cheers
Franz


"Teemu Lahti" <teelNO at SPAMbooze.de> schrieb im Newsbeitrag
news:atn1tq$d8u$1 at phys-news1.kolumbus.fi...
> I have this very beginner problem. I need to sort dictionary by its
values.
> I know how to do it by its keys, but I have no idea how to do it with its
> values. Any ideas? :)
>
> // Teel
>
>





More information about the Python-list mailing list