You are given a String[], names, which is a list of the names of all of
your existing clients. Some of the names are in "First Last" format,
while the rest are in "Last, First" format. You are to return a String[]
with all of the names in "First Last" format, sorted by last name, then
by first name.
names will contain between 1 and 50 elements,
inclusive.
names will be of the form "First Last" or "Last, First" (quotes added for clarity).
names will contain between 3 and 50 characters, inclusive.
{"Joe Smith", "Brown, Sam", "Miller, Judi"}
Returns: { "Sam Brown", "Judi Miller", "Joe Smith" }
The last names, in order, are Brown, Miller, Smith. We
rearrange each name to be in the proper format also.
{"Campbell, Phil", "John Campbell", "Young, Warren"}
Returns: { "John Campbell", "Phil Campbell", "Warren Young" }
Notice here how we sort by first name when the last names
are the same.
{"Kelly, Anthony", "Kelly Anthony", "Thompson, Jack"}
Returns: { "Kelly Anthony", "Anthony Kelly", "Jack Thompson" }
Be careful to properly identify first name versus last name!
{"Trevor Alvarez", "Jackson, Walter", "Mandi Stuart",
"Martin, Michael", "Peters, Tammy", "Richard Belmont",
"Carl Thomas", "Ashton, Roger", "Jamie Martin"}
Returns:
{
"Trevor Alvarez",
"Roger Ashton",
"Richard Belmont",
"Walter Jackson",
"Jamie Martin",
"Michael Martin",
"Tammy Peters",
"Mandi Stuart",
"Carl Thomas" }
{"Banks, Cody", "Cody Banks", "Tod Wilson"}
Returns: { "Cody Banks", "Cody Banks", "Tod Wilson" }
Notice that two identical names can appear in the list.
{"Mill, Steve", "Miller, Jane"}
Returns: { "Steve Mill", "Jane Miller" }
Notice that shorter names precede longer names alphabetically when the shorter name is a substring of the longer.