JAVA: Sort a list of words by length, then by alphabetical order

I am told to have a list of words sorted by length, and those that have the same length are sorted by alphabetical order. This is what I have for the method that does that so far.

public static void doIt(BufferedReader r, PrintWriter w) throws IOException {
    TreeMap<String, Integer> s = new TreeMap<String, Integer>();
    ArrayList<Integer> count = new ArrayList<Integer>();
    String line;
    int length;
    while ((line = r.readLine()) != null) {
        length = line.length();

        s.put(line, length);
        if (!count.contains(length)){

My mindset was to use a TreeMap to keep the String, and the length of the word as the key. I also have an ArrayList that keeps track of all the word’s lengths without any duplicates, it’s then sorted.

I was hoping to somehow call on the TreeMap for the key value of 5, which would list all the words with 5 letters in it.

I was wondering if I’m on the right track? I’ve been playing around for over an hour and can’t seem to figure out what I should do after this. Am I approaching this from the right angle?

Taylor Swift by Damon Baker for Grazia France October 2014

Taylor Swift – Damon Baker Photoshoot 2014

4 jpg | up to 1045*1567 | 1.89 Mb

American singer and actress

Flea Market Decor Magazine Midcentury Mod 2015 (True PDF)

Flea Market D?cor Magazine Midcentury Mod 2015 (True PDF)


Flea Market Décor Magazine Midcentury Mod 2015
English | 132 Pages | True PDF | 24MB

Simone Sarasso – Il paese che amo (repost)

=”″ rel=”nofollow”>

PixAndVideo – Aletta Ocean (Private rehearsal) 10-October-2015

Category: Movies
Seeder: 0
Leecher: 0
Size: 411.95 MB

See more @