r/PythonLearning • • Aug 20 '25

Bubble sort first time

Post image
70 Upvotes

12 comments sorted by

5

u/Capable-Package6835 Aug 20 '25

In Python you can also swap directly without a dummy variable:

l[j], l[j+1] = l[j+1], l[j]

4

u/Aicanaro6558 Aug 20 '25

In the future, try to get rid of single-letter variables, and do not name the variables l and o, as they are very similar to 1 and 0, good luck with programming!

1

u/AroshWasif Aug 20 '25

Thanks 🙂

3

u/[deleted] Aug 20 '25

Babble lmaooo

2

u/gigsoll Aug 20 '25

You are stepped on the sorting algorithms road, now you need to implement bogosort and other great ones

3

u/Fit-Grass7102 Aug 20 '25

Soviet Sort best

2

u/gigsoll Aug 20 '25

Oh yeah, linear time complexity