Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/estebanborai/selection-sort-js
A "Selection Sort" algorithm implementation in JavaScript
https://github.com/estebanborai/selection-sort-js
algorithm javascript selection-sort
Last synced: about 2 months ago
JSON representation
A "Selection Sort" algorithm implementation in JavaScript
- Host: GitHub
- URL: https://github.com/estebanborai/selection-sort-js
- Owner: EstebanBorai
- License: mit
- Archived: true
- Created: 2020-01-16T01:14:29.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2021-11-09T04:12:37.000Z (about 3 years ago)
- Last Synced: 2024-04-26T19:21:19.146Z (7 months ago)
- Topics: algorithm, javascript, selection-sort
- Language: JavaScript
- Size: 1.1 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# selection-sort-js
A "Selection Sort" algorithm implementation in JavaScript## Installation
```bash
npm install @estebanborai/selection-sort
```## Usage
### `selectionSort(arr: Array): Array`
Sorts an array of numbers```javascript
import selectionSort from '@estebanborai/selection-sort';const items = [-1, 10, 2, 0, 6, 8];
const sorted = selectionSort(items);console.log(sorted); // [-1, 0, 2, 6, 8, 10]
```### `findSmallest(arr: Array): number`
Returns the index of the smallest number in the array.
_This function is used internally by `selectionSort` and exported._```javascript
import { findSmallest } from '@estebanborai/selection-sort';const items = [1, 25, 88, -10, 11];
const smallestItemIndex = findSamallest(items);console.log(smallestItemIndex); // 3
```## License
Licensed under the MIT License