How to sort a list in python without sort function?
In python when ever we want to sort a list we use sort() function.
As sort function makes it very easy to sort a list in python.
We can sort it without sort function also. And we’ll see it here.
e.g.,
l = [4, 8, 2, 1, 3, 9, 20, 15, 10, 33] n = [] while l: min = l[0] for i in l: if i < min: min = i n.append(min) l.remove(min) print(n)
This is how we can sort list in python without sort function.
Subscribe
Login
Please login to comment
0 Discussion