About 1,550,000 results
Open links in new tab
  1. 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 …

  2. 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?

  3. python - Sort a list of numbers by absolute value (ignoring ...

    l.sort(key= abs, reverse = True) Lists can be sorted using the sort () method. And the sort method has a parameter, called key, which you can pass a function. Using this parameter, your list …

  4. python - How do I sort a list of objects based on an attribute of …

    I have a list of Python objects that I want to sort by a specific attribute of each object:

  5. python - How to sort a list of lists by a specific index of the inner ...

    16 array.sort(key = lambda x:x[1]) You can easily sort using this snippet, where 1 is the index of the element.

  6. python - What is the difference between sorted (list) vs list.sort ...

    The .sort () function stores the value of new list directly in the list variable; so answer for your third question would be NO. Also if you do this using sorted (list), then you can get it use because it …

  7. python - How do I sort a list of datetime or date objects ... - Stack ...

    Jan 23, 2013 · If your list is a mixture of date and datetimes, you can normalize them all into datetime objects, and then sort; again, as a key so that the type of the items in the original list …

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

    Nov 20, 2010 · Here's one way: You basically re-write your sort function to take a list of sort functions, each sort function compares the attributes you want to test, on each sort test, you …

  9. Python list sort in descending order - Stack Overflow

    Apr 20, 2010 · If there is another variable aliasing the original list, its value afterwards will not have the elements in their original order, nor in descending order; the alias will point at a list …

  10. python - Sort a part of a list in place - Stack Overflow

    Feb 16, 2010 · A good reason for in-place sort is a case where you want to sort the end of the list (that is already mostly sorted, perhaps by a less-expensive key function), and then pop the last …