merge-srt

1.1.0 • Public • Published




merge-srt : Merge Sort Algorithm Implementation

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

Package Sidebar

Install

npm i merge-srt

Weekly Downloads

0

Version

1.1.0

License

MIT

Unpacked Size

5.34 kB

Total Files

4

Last publish

Collaborators

  • abranhe