I've tried numerous solutions and am really struggling here.
I have an arraylist full of strings ranging in length.
I need to sort the strings alphabetically by the last word in each string.
Some strings are entered as "Unknown" while others are multiple words.
Example:
static List<String> authors = new ArrayList<>();
authors.add("Unknown");
authors.add("Hodor");
authors.add("Jon Snow");
authors.add("Sir Jamie Lannister");
sort(authors);
System.out.println(authors);
Should return:
Hodor
Sir Jamie Lannister
Jon Snow
Unknown
How can i iterate this list sorting by the last name / word in each string?
Thanks immensely for any suggestions. I Will continue to google in the meantime.