Skip to content
This repository was archived by the owner on Nov 9, 2021. It is now read-only.

StudyResearchProjects/selection-sort-js

Repository files navigation

selection-sort-js

A "Selection Sort" algorithm implementation in JavaScript

Installation

npm install @estebanborai/selection-sort

Usage

selectionSort(arr: Array<number>): Array<number>

Sorts an array of numbers

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>): number

Returns the index of the smallest number in the array. This function is used internally by selectionSort and exported.

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

About

A "Selection Sort" algorithm implementation in JavaScript

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •