Skip to content

Latest commit

 

History

History

bubble-sort

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

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]