Challenge: Bubble Sort the Slice

This lesson brings you a challenge to solve.

Problem statement #

Sort a slice of integers through a function that implements the Bubble sort algorithm. Look up the definition of this algorithm here.

Input #

Unsorted slice

Sample input #

[4 5 2 1 3]

Output #

Sorted slice

Sample output #

[1 2 3 4 5]

Try to implement the function below. Feel free to view the solution, after giving some shots. Good Luck!

Get hands-on with 1200+ tech skills courses.