public static void radixSortVarLengthMsd( String []words, int maxLen ) {

        java.util.List<java.util.List<String>> lengthBuckets = new ArrayList<java.util.List<String>>();

        for (int i = 0; i < words.length; i++)
            lengthBuckets.add(new ArrayList<String>());


        // create buckets for each length and sort the strings by length into each bucket.
        for (String s : words)
            lengthBuckets.get(s.length()).add(s);

        //FILL LENGTH BUCKETS
        // reinit array so all strings are sorted by length, not alpha yet !
        int idx = 0;
        for (java.util.List<String> lengthBucket : lengthBuckets)
            for (String fixedLengthStr : lengthBucket)
                words[idx++] = fixedLengthStr;

        // now starting with longest strings, go bucket by bucket to shortest strings
        // subsequent passes as we move the position to the right will include the already
        // sorted longer strings
        int startingStrIndex = words.length;

        java.util.List<java.util.List<String>> alphaBuckets = new ArrayList<java.util.List<String>>();
        for (int i = 0; i < 256; i++)
            alphaBuckets.add(new ArrayList<String>());

        for (int charPos = maxLen - 1; charPos >= 0; charPos--) {
            // index into arr for strings of the same length
            startingStrIndex -= lengthBuckets.get(charPos + 1).size();

            // FILL ALPHA BUCKET
            // index into arr for strings of the same length
            // NOW WE ADD TO ALPHA BUCKET based on pos value from arr
            // Do this for each string of this length
            for (int i = startingStrIndex; i < words.length; i++) {
                alphaBuckets.get(words[i].charAt(charPos)).add(words[i]);
            }

            //EMPTY ALPHA BUCKET
            // NOW we iterate over ALPHA buckets one at a time and
            // enqueue in order to arr starting from startingIndex.
            // This sorts all the strings of that length
            idx = startingStrIndex;
            for (java.util.List<String> alphaBucket : alphaBuckets) {
                for (String s : alphaBucket) {
                    words[idx++] = s; // adds in sorted order !
                }

                alphaBucket.clear();
            }
        }
    }