There are many ways of doing it, here are some hints:
1. Use a hashvalue as key instead of length.
2. If you have a static array, calculate the hashkeys of each string, then sort the arrays (hashkey array+string array) and use binary search to find the first hashkey. Then compare each string with the same hashkey.
3. If you have a dynamic array, I would recommend to use a hashmap which allows multiple entries with the same hashkey or use list/vector to save the list of strings having the same hashkey, something like this: