Lets say we have List of suffixes for String banana - banana, anana, nana, ana, na, a. I was able to put each suffix in a bucket. like suffix that starts from ‘a’ will be in one bucket and suffix that starts with ‘b’ will be in other bucket. Same for n as well. But I was not able to sort strings lexicographically in a bucket efficiently. say bucket a should look like this - a, ana, anana. Because of this I am not able to solve this problem efficiently in java .I have been stuck for days now. Any piece of code/suggestions is much appreciated.