Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/abranhe/bubble-srt
Bubble Sort Algorithm Implementation
https://github.com/abranhe/bubble-srt
algorithm bubble-sort sorting-algorithms
Last synced: 4 days ago
JSON representation
Bubble Sort Algorithm Implementation
- Host: GitHub
- URL: https://github.com/abranhe/bubble-srt
- Owner: abranhe
- License: mit
- Created: 2018-08-19T15:43:37.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2018-08-19T19:53:15.000Z (about 6 years ago)
- Last Synced: 2024-10-12T12:15:07.570Z (about 1 month ago)
- Topics: algorithm, bubble-sort, sorting-algorithms
- Language: JavaScript
- Homepage: https://npm.im/bubble-srt
- Size: 3.91 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
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
```js
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' ]
```# Related
- [bubble-srt-cli](https://github.com/abranhe/bubble-srt-cli): CLI for this module
# Team|[![Carlos Abraham Logo](https://avatars3.githubusercontent.com/u/21347264?s=50&v=4)](https://19cah.com)|
| :-: |
| [Carlos Abraham](https://github.com/abranhe) |# License
[MIT](https://github.com/abranhe/bubble-srt/blob/master/LICENSE) License © [Carlos Abraham](https://github.com/abranhe/)