About 11,300,000 results
Open links in new tab
  1. python - What is the difference between sorted (list) vs list.sort ...

    445 sorted() returns a new sorted list, leaving the original list unaffected. list.sort() sorts the list in-place, mutating the list indices, and returns None (like all in-place operations). sorted() works on any …

  2. What algorithm does python's sorted() use? - Stack Overflow

    Jun 8, 2012 · In Python 2.7, how does Python's built-in sorted function work - what algorithm does it use?

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

    Jan 26, 2017 · There are a number of Python modules that provide dictionary implementations which automatically maintain the keys in sorted order. Consider the sortedcontainers module which is pure …

  4. How to sort Counter by value? - python - Stack Overflow

    Other than doing list comprehensions of reversed list comprehension, is there a pythonic way to sort Counter by value? If so, it is faster than this: >>> from collections import Counter &...

  5. python - Sort a list by multiple attributes? - Stack Overflow

    Nov 20, 2010 · It appears you could use a list instead of a tuple. This becomes more important I think when you are grabbing attributes instead of 'magic indexes' of a list/tuple. In my case I wanted to sort …

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

    Python has supported the key= for .sort since 2.4, that is year 2004, it does the Schwartzian transform within the sorting code, in C; thus this method is useful only on Pythons 2.0-2.3. all of which are more …

  7. python - How to sort a list of strings? - Stack Overflow

    Aug 30, 2008 · What is the best way of creating an alphabetically sorted list in Python?

  8. What is `lambda` in Python code? How does it work with `key` …

    I saw some examples using built-in functions like sorted, sum etc. that use key=lambda. What does lambda mean here? How does it work? For the general computer science concept of a lambda, see …

  9. How to use sort() for set() values in Python? - Stack Overflow

    Nov 12, 2019 · How to use sort () for set () values in Python? Asked 6 years, 1 month ago Modified 6 years, 1 month ago Viewed 17k times

  10. Does Python have an ordered set? - Stack Overflow

    Oct 31, 2009 · 28 If you're using the ordered set to maintain a sorted order, consider using a sorted set implementation from PyPI. The sortedcontainers module provides a SortedSet for just this purpose. …