About 456,000 results
Open links in new tab
  1. python - How do I sort a dictionary by value? - Stack Overflow

    Mar 5, 2009 · I have a dictionary of values read from two fields in a database: a string field and a numeric field. The string field is unique, so that is the key of the dictionary. I can sort on the keys, but ...

  2. python - How do I sort a dictionary by key? - Stack Overflow

    Jan 26, 2017 · From python 3.7.4 manual: "Performing list (d) on a dictionary returns a list of all the keys used in the dictionary, in insertion order". So insertion order is something which is preserved and we …

  3. How can I sort a list of dictionaries by a value of the dictionary in ...

    How can I sort a list of dictionaries by a value of the dictionary in Python? Asked 17 years, 3 months ago Modified 5 months ago Viewed 1.5m times

  4. How to sort dictionaries by keys in Python - Stack Overflow

    It's worth noting that Python has a number of dictionary implementations that maintain the keys in sorted order. Consider the sortedcontainers module which is pure-Python and fast-as-C implementations.

  5. sorting dictionary python 3 - Stack Overflow

    May 26, 2017 · A modern and fast solution, for Python 3.7. May also work in some interpreters of Python 3.6. TLDR To sort a dictionary by keys use:

  6. Sort Dict by Values in Python 3.6+ - Stack Overflow

    Sep 3, 2018 · Sort Dict by Values in Python 3.6+ Asked 7 years, 3 months ago Modified 1 year, 11 months ago Viewed 43k times

  7. Python 3 sort a dict by its values - Stack Overflow

    Oct 5, 2015 · To sort a dictionary and keep it functioning as a dictionary afterwards, you could use OrderedDict from the standard library. If that's not what you need, then I encourage you to reconsider …

  8. Fastest way to sort a python 3.7+ dictionary - Stack Overflow

    Now that the insertion order of Python dictionaries is guaranteed starting in Python 3.7 (and in CPython 3.6), what is the best/fastest way to sort a dictionary - both by value and by key?

  9. python - Sort dict alphabetically - Stack Overflow

    Apr 14, 2015 · My program can output every student's name and their 3 scores from a dict in a file, but I need to sort the data by alphabetical order. How can I sort the names and scores alphabetically …

  10. dictionary - sort dict by value python - Stack Overflow

    48 If you actually want to sort the dictionary instead of just obtaining a sorted list use collections.OrderedDict