About 7,240,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 list of objects based on an attribute of the ...

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

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

  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 - Sort a list of lists with a custom compare function - Stack ...

    For anyone who is new to python or coming from a c++ background. we want to replicate to use of the call-back function here like c++. I tried this with the sorted () function. For example: if we wanted to …

  6. Sorting a Python list by two fields - Stack Overflow

    I have the following list created from a sorted csv list1 = sorted(csv1, key=operator.itemgetter(1)) I would actually like to sort the list by two criteria: first by the value in field 1 and then ...

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

  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. sorting - How does the key argument in python's sorted function work ...

    The parameter passed to key must be something that is callable. The use of lambda creates an anonymous function (which is callable). In the case of sorted the callable only takes one parameters. …

  10. python - What is the complexity of the sorted () function ... - Stack ...

    Jan 21, 2013 · I have a list of lists and I am sorting them using the following data=sorted(data, key=itemgetter(0)) Was wondering what is the runtime complexity of this python function?