UNPKG

hd-utils

Version:

A handy utils for modern JS developers

12 lines (11 loc) 428 B
import { StringOrNumber } from '../types'; /** * @description an implementation for mergeSort algorithm, it will sort an array of numbers or strings. * @example * const arrayToSort = [3, 1,-1, 0, 4, 1, 5, 9, 2, 6, 5, 3, 5]; mergeSort(arrayToSort) // [ -1, 0, 1, 1, 2, 3, 3, 4, 5, 5, 5, 6, 9 ]; * @param left * @param right * @returns */ export default function mergeSort<T extends StringOrNumber>(arr: T[]): T[];