sorting/msd

Sorts given array lexicographically. Algorithms knows how to treat differently length strings.

Algorithm is stable. Time complexity: O(N*M) for N keys which have M or fewer digits.
Source:
Parameters:
Name Type Description
arr Array Array which should be sorted.
d Number Optional. Digit from which sorting should start.
Returns:
Type:
Array
Sorted array.
Example
var sort = require('../src/sorting/msd').msd;
// [ 'aab', 'aaa', 'acc', 'bbb', 'bcc' ]
console.log(sort(['aab', 'bbb', 'aaa', 'acc', 'bcc']));