Sorts strings lexicographically.
Time complexity: O(N*M) for N keys which have M or fewer digits.
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. |
letterIdx |
Number
|
Optional. Index to start sorting from. |
Returns:
- Type:
-
Array
Sorted array.
Example
var sort = require('../src/sorting/lsd').lsd;
// [ 'aab', 'aaa', 'acc', 'bbb', 'bcc' ]
console.log(sort(['aab', 'bbb', 'aaa', 'acc', 'bcc']));