creating a hash based sorting algorithm
You have reinvented a form of radix sort.
See that page for how to get rid of the two nested O(n) loops.

It is possible to get O(n) if the maximum length of the words to be sorted is assumed to be a constant.