About 2,950,000 results
Open links in new tab
  1. 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:

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

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

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

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

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

    I have some data either in a list of lists or a list of tuples, like this: data = [[1,2,3], [4,5,6], [7,8,9]] data = [(1,2,3), (4,5,6), (7,8,9)] And I want to sort by the 2nd element in the subset.

  7. sorting - How to sort with lambda in Python - Stack Overflow

    Sep 22, 2010 · How to sort with lambda in Python Asked 15 years, 1 month ago Modified 1 year, 9 months ago Viewed 663k times

  8. python - pandas groupby, then sort within groups - Stack Overflow

    I want to group my dataframe by two columns and then sort the aggregated results within those groups. In [167]: df Out[167]: count job source 0 2 sales A 1 4 sales B...

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

    Nov 20, 2010 · I had a list of tuples that needed sorting 1st by descending integer values and 2nd alphabetically. This required reversing the integer sort but not the alphabetical sort.

  10. python - Sorting a list of dot-separated numbers, like software ...

    Sorting a list of dot-separated numbers, like software versions Asked 15 years, 7 months ago Modified 9 months ago Viewed 59k times