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 ascending ordert in Python
Python Online Editor
Execute Code
More Python Sample Codes
# To sort list element in ascending order use sort() method int_list = [6, 7, 1, 4, 5, 8, 2, 3, 9] print("Original unordered list: ", int_list) int_list.sort() # sort() method is used to sort the list elements print("Sorted list elements in ascending order:", int_list, "\n") str_list = ["banana", "apple", "orange", "mango" ] print("Original unordered list: ", str_list) str_list.sort() # sort() method is used to sort the list elements print("Sorted list elements in ascending order:", str_list) print("\nList elements can also be sorted using sorted() function") # To sort list element in ascending order use sorted() function sorted(str_list) print("Sorted list elements in ascending order:", str_list)