Skip to content

Latest commit

 

History

History
17 lines (10 loc) · 553 Bytes

README.md

File metadata and controls

17 lines (10 loc) · 553 Bytes

Bubble sort

Description

Bubble sort is a simple sorting algorithm that repeatedly steps through the list, compares adjacent pairs and swaps them if they are in the wrong order.

The pass through the list is repeated until the list is sorted. The algorithm, which is a comparison sort, is named for the way smaller or larger elements "bubble" to the top of the list.

Implementation

bubbleSort(array) should return the origin array, sorted with bubble sort.

Example:

bubbleSort([5, 3, 8, 2, 1, 4]) //  [1, 2, 3, 4, 5, 8]