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

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

    Aug 30, 2008 · As sort() sorts the list in place (ie, changes the list directly), it doesn't return the sorted list, and actually doesn't return anything, so your print statement prints None. If you …

  3. How do you sort a list of integers by ascending order?

    Oct 4, 2018 · When you say that .sort () is ignoring numbers larger than 9, can you provide an example of the output you are getting, to compare to the output you expect? .sort () is the …

  4. python - Order a list of numbers without built-in sort, min, max ...

    while data_list: new_list.append(heapq.heappop(data_list))) I suggest having a look in the Python library for heapq.py to see how it works. Heapsort is quite a fun sorting algorithm as it lets you …

  5. python - How can i sort a list by the second item descending and …

    Dec 11, 2021 · Another possibility is to sort only once, using a tuple as the key. Python's sorted and list.sort both offer a reverse= True or False argument to specify a sort in increasing or …

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

    @Cemre as for the second example, sort here is a method of List object of Python, which receives a lambda function as its key parameter. You may name it as tup, or t, or whatever …

  7. How to get indices of a sorted array in Python - Stack Overflow

    313 I have a numerical list: myList = [1, 2, 3, 100, 5] Now if I sort this list to obtain [1, 2, 3, 5, 100]. What I want is the indices of the elements from the original list in the sorted order i.e. [0, 1, 2, …

  8. python - Sort a list of numerical strings in ascending order - Stack ...

    Mar 18, 2012 · I have created an SQLite database which has a table which stores temperature values. The temperature values are written to the database in ascending order for the first …

  9. python - Sort filenames in directory in ascending order - Stack …

    Sort filenames in directory in ascending order [duplicate] Asked 10 years ago Modified 2 years, 1 month ago Viewed 170k times

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