[SOLVED] Efficient string sorting algorithm


Sorting strings by comparisons (e.g. standard QuickSort + strcmp-like function) may be a bit slow, especially for long strings sharing a common prefix (the comparison function takes O(s) time, where s is the length of string), thus a standard solution has the complexity of O(s * nlog n). Are there any known faster algorithms?


If you know that the string consist only of certain characters (which is almost always the case), you can use a variant of BucketSort or RadixSort.

Answered By – phimuemue

Answer Checked By – Katrina (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *