Write a method named split
that accepts a Set
of strings as a parameter and returns the result of splitting the strings into different sets based on the length of the strings.
In particular, your method should return a map whose keys are integers representing string lengths, and whose values are sets of strings of that length.
Within each set in your result, the strings should be sorted in alphabetical order.
For example, if a variable called words
contains the following set of strings:
[to, be, or, not, that, is, the, question]
Then the call of split(words)
should return the following map:
{2=[be, is, or, to], 3=[not, the], 4=[that], 8=[question]}
Do not modify the set passed in as the parameter.