Below you can see my code. It reads words from dictionary and copy words that match specific patern to test.txt. My qusetion is how to sort words in test.txt first by LENGTH and
You should define a Comparator, so that it compares the two strings in a right manner. In your case, the shorter string will go prior to a longer string; if sizes are equal - the order is alphabetic.
Then you use this Comparator to do the sorting - use Collections.sort() for it.