About 7,980,000 results
Open links in new tab
  1. sorting - How to sort with lambda in Python - Stack Overflow

    Sep 22, 2010 · 15 You're trying to use key functions with lambda functions. Python and other languages like C# or F# use lambda functions. Also, when it comes to key functions and according to the …

  2. python - How do I sort a list of objects based on an attribute of the ...

    14 Add rich comparison operators to the object class, then use sort () method of the list. See rich comparison in python. Update: Although this method would work, I think solution from Triptych is …

  3. 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 value. Ran …

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

    Aug 30, 2008 · 8 But how does this handle language specific sorting rules? Does it take locale into account? No, list.sort() is a generic sorting function. If you want to sort according to the Unicode …

  5. 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 ...

  6. python - Sorting a set of values - Stack Overflow

    Since Python 3.7, dicts keep insertion order. So if you want to order a set but still want to be able to do membership checks in constant time, you can create a dictionary from the sorted list using …

  7. 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 …

  8. python - Sorting arrays in NumPy by column - Stack Overflow

    May 13, 2010 · Sorting arrays in NumPy by column Asked 15 years, 7 months ago Modified 3 years, 6 months ago Viewed 567k times

  9. python - Syntax behind sorted (key=lambda: ...) - Stack Overflow

    I don't quite understand the syntax behind the sorted() argument: key=lambda variable: variable[0] Isn't lambda arbitrary? Why is variable stated twice in what looks like a dict?

  10. python - How to sort a list/tuple of lists/tuples by the element at a ...

    Below example, we are sorting a list of tuple that holds the info abt time of certain event and actor name. We are sorting this list by time of event occurrence - which is the 0th element of a tuple.