# bubble-srt

Bubble Sort Algorithm Implementation

## Usage no npm install needed!

``````<script type="module">
import bubbleSrt from 'https://cdn.skypack.dev/bubble-srt';
</script>``````

bubble-srt : Bubble Sort Algorithm Implementation

# Overview

Bubble sort, sometimes referred to as sinking sort, is a simple sorting algorithm that repeatedly steps through the list to be sorted, compares each pair of adjacent items and swaps them if they are in the wrong order.

The pass through the list is repeated until no swaps are needed, which indicates that 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. Although the algorithm is simple, it is too slow and impractical for most problems even when compared to insertion sort. Bubble sort can be practical if the input is in mostly sorted order with some out-of-order elements nearly in position

# Install

``````npm install bubble-srt
``````

# Usage

``````const bubbleSort = require('bubble-srt');

let numsArr = [46, 24, 33, 10, 2, 81, 50];
console.log(bubbleSort(numsArr));
// => [ 2, 10, 24, 33, 46, 50, 81 ]

let lettersArr = ['d', 'h', 'z', 'a', 'r', 'b', 'i'];
console.log(bubbleSort(lettersArr));
// => [ 'a', 'b', 'd', 'h', 'i', 'r', 'z' ]

let wordsArr = ['happy', 'auto', 'energy', 'zoo', 'trigonometry', 'dog', 'foo'];
console.log(bubbleSort(wordsArr));
// => [ 'auto', 'dog', 'energy', 'foo', 'happy', 'trigonometry', 'zoo' ]
``````