xFactorSchool.com(Beta)
How to Do Examples
Python Examples
HTML Examples
Code Examples
C Code Examples
C++ Code Examples
C# Code Examples
Java Code Examples
Python Code Examples
HTML Code Examples
CSS Code Examples
JavaScript Code Examples
Online Editor
C Code Editor
C++ Code Editor
C# Code Editor
Java Code Editor
Python Code Editor
HTML Code Editor
CSS Code Editor
JavaScript Code Editor
Practice how to sort list elements in descending order in Python
Python Online Editor
Execute Code
More Python Sample Codes
# To sort list element in descending order use sort() method with reverse parameter int_list = [6, 7, 1, 4, 5, 8, 2, 3, 9] print("Original unordered list: ", int_list) int_list.sort(reverse=True) # sort() method is used to sort the list elements print("Sorted list elements in descending order:", int_list, "\n") str_list = ["banana", "apple", "orange", "mango" ] print("Original unordered list: ", str_list) str_list.sort(reverse=True) # sort() method is used to sort the list elements print("Sorted list elements in descending order:", str_list) print("\nList elements can also be sorted using sorted() function with reverse parameter") # To sort list element in descending order use sorted() function with reverse parameter sorted(str_list, reverse=True) print("Sorted list elements in descending order:", str_list)