Search code examples
pythonlistsorting

Identifying Sorting Method in Python


I wrote the following code while exploring sorting algorithms, but I'm unsure about the specific sorting method it represents. Can someone help me identify it?

a = [64, 25, 12, 22, 11]
sorted_lis=[]

while not len(a)==0:
    sorted_lis.append(min(a))
    a.remove(min(a))

print(sorted_lis)

Appreciate any suggestions and insights into the sorting technique used in this code. Also if there are more efficient ways to achieve the same result, feel free to share your recommendations.


Solution

  • There is no algorithm in which we remove element but we can say it as selection sort because every time we are selecting minimum element from a list and in selection sort we do same thing.