1.1.0 • Published 6 years ago

merge-srt v1.1.0

Weekly downloads
7
License
MIT
Repository
github
Last release
6 years ago

Overview

In computer science, merge sort is an efficient, general-purpose, comparison-based sorting algorithm. Most implementations produce a stable sort, which means that the implementation preserves the input order of equal elements in the sorted output.

Merge sort is a divide and conquer algorithm that was invented by John von Neumann in 1945. A detailed description and analysis of bottom-up mergesort appeared in a report by Goldstine and von Neumann as early as 1948.

Read More ...

Install

npm install merge-srt

Usage

const mergeSort = require('merge-srt');

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

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

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

API

mergeSort(array)

Return a sorted array using merge sort algorithm

Related

Team

Carlos Abraham Logo
Carlos Abraham

License

MIT License © Carlos Abraham