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.
Parameters:
| Name | Type | Description |
|---|---|---|
arr |
Array | Array which should be sorted. |
letterIdx |
Number | Optional. Index to start sorting from. |
- Source:
Returns:
Sorted array.
- Type
- Array
Example
var sort = require('../src/sorting/lsd').lsd;
// [ 'aab', 'aaa', 'acc', 'bbb', 'bcc' ]
console.log(sort(['aab', 'bbb', 'aaa', 'acc', 'bcc']));