This will give you a sorted version of the array.
sorted(timestamps, reverse=True)
If you want to sort in-place:
timestamps.sort(reverse=True)
Check the docs at Sorting HOW TO
Answer from Marcelo Cantos on Stack OverflowPython documentation
docs.python.org › 3 › howto › sorting.html
Sorting Techniques — Python 3.14.3 documentation
February 23, 2026 - Both list.sort() and sorted() accept a reverse parameter with a boolean value. This is used to flag descending sorts.
Top answer 1 of 7
603
This will give you a sorted version of the array.
sorted(timestamps, reverse=True)
If you want to sort in-place:
timestamps.sort(reverse=True)
Check the docs at Sorting HOW TO
2 of 7
430
In one line, using a lambda:
timestamps.sort(key=lambda x: time.strptime(x, '%Y-%m-%d %H:%M:%S')[0:6], reverse=True)
Passing a function to list.sort:
def foo(x):
return time.strptime(x, '%Y-%m-%d %H:%M:%S')[0:6]
timestamps.sort(key=foo, reverse=True)
How to use sorted () function with reverse=True.
You can refer to the documentation for other use cases but you can simply use it like sorted_list = sorted(original_list, reverse=True) More on reddit.com
Using sorted() to print a list in reverse alphabetical order
Can anyone help me use sorted() to print a list in reverse alphabetical order please? Here is my list: places = [‘Iceland’, ‘Japan’, ‘Manchester’, ‘Norwich’] As I understand it, the sorted() function can also accept a… More on discuss.python.org
This will give you a sorted version of the array.
sorted(timestamps, reverse=True)
If you want to sort in-place:
timestamps.sort(reverse=True)
Check the docs at Sorting HOW TO
Answer from Marcelo Cantos on Stack OverflowVideos
07:09
Sorting and Reversing a list| Python for Beginners | Module 03 ...
10:06
How to Order Lists in Python (Visually Explained) | sort(), sorted(), ...
03:59
Python list sort, sorted, and reverse (CS105 at UIUC) - YouTube
List.sort(), Sorted(list), List.reverse(), sort(reverse=True), ...
14 The reverse and sort Methods
Wikipedia
en.wikipedia.org › wiki › Reverse_Polish_notation
Reverse Polish notation - Wikipedia
February 8, 2026 - During the 1970s and 1980s, Hewlett-Packard used RPN in all of their desktop and hand-held calculators, and has continued to use it in some models into the 2020s. In computer science, reverse Polish notation is used in stack-oriented programming languages such as Forth, dc, Factor, STOIC, PostScript, RPL, and Joy.
Reddit
reddit.com › r/pythonlearning › how to use sorted () function with reverse=true.
r/PythonLearning on Reddit: How to use sorted () function with reverse=True.
June 5, 2025 -
I'm learning python on my own and got the "Python Crash Course" book and I'm stuck on trying to sort a list in reverse using the sorted () function.
Programiz
programiz.com › python-programming › methods › built-in › sorted
Python sorted()
Here, sorted(iterable, reverse = True) sorts the list in descending order. The sorted() method accepts another optional parameter- the key function. For example, ... Here, len is Python's built-in function that counts the length of an element.
W3Schools
w3schools.com › python › ref_func_sorted.asp
Python sorted() Function
Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Bootcamp Python Certificate Python Training ... The sorted() function returns a sorted list of the specified iterable object. You can specify ascending or descending order. Strings are sorted alphabetically, and numbers are sorted numerically. Note: You cannot sort a list that contains BOTH string values AND numeric values. ... a = ("h", "b", "a", "c", "f", "d", "e", "g") x = sorted(a, reverse=True) print(x) Try it Yourself »
AlgoExpert
algoexpert.io › questions
AlgoExpert | Ace the Coding Interviews
The leading platform to prepare for coding interviews. Master essential algorithms and data structures, and land your dream job with AlgoExpert.
W3Schools
w3schools.com › python › python_lists_sort.asp
Python - Sort Lists
The reverse() method reverses the current sorting order of the elements.
Programiz
programiz.com › python-programming › methods › list › sort
Python List sort()
Become a certified Python programmer. Try Programiz PRO! ... The list's sort() method sorts the elements of a list. ... # sort the list in ascending order prime_numbers.sort() print(prime_numbers) # Output: [2, 3, 5, 7, 11] ... We can sort a list in descending order by setting reverse to True.
GeeksforGeeks
geeksforgeeks.org › python › python-list-sort-method
Python List sort() Method - GeeksforGeeks
December 20, 2025 - To sort values from highest to lowest, we use the reverse=True parameter. ... The key parameter allows sorting based on a custom rule. For example, strings can be sorted by their length instead of alphabetical order.
Mimo
mimo.org › glossary › python › list-sort()
Python List sort(): Master Data Sorting | Learn Now
You can sort the list in descending order by passing reverse=True as an argument: ... This method sorts the list based on the specified sorting criteria, making it one of Python's most commonly used features for data organization.
GeeksforGeeks
geeksforgeeks.org › python › python-reverse-order-sort-in-string-list
Python | Reverse Order Sort in String List - GeeksforGeeks
May 3, 2023 - The reverse logic is implemented by passing "reverse" as True parameter to sorted(). ... # Python3 code to demonstrate working of # Reverse Order Sort in String List # using list comprehension + sorted() + join() + reverse # initialize list ...