Python Programs | IT Developer
IT Developer

Python Programs



Share with a Friend

Python Programs - Functions

Function to sort a list without using sort() - Python Program

Example 1 :

def manual_sort(lst): """Sort list without sort() method.""" for i in range(len(lst)): for j in range(i+1, len(lst)): if lst[i] > lst[j]: lst[i], lst[j] = lst[j], lst[i] return lst print(manual_sort([5, 2, 9, 1]))

Output

 
OUTPUT  :
[1, 2, 5, 9]