Learn

Bubble sort is an algorithm to sort a list through repeated swaps of adjacent elements. It has a runtime of `O(n^2)`

.

For nearly sorted lists, bubble sort performs relatively few operations since it only performs a swap when elements are out of order.

Bubble sort is a good introductory algorithm which opens the door to learning more complex algorithms. It answers the question, “How can we algorithmically sort a list?” and encourages us to ask, “How can we improve this sorting algorithm?”

### Instructions

Does bubble sort have to sort in ascending order?

# Sign up to start coding

By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.