PROBLEM STATEMENT
According to local alphabetization customs of the country where your software
has to be deployed, characters 'c' and 's' are sorted differently when the 'h'
character follows them. Character group 'ch' sorts as if it were a single
character that appears between the characters 'c' and 'd'; character group 'sh'
sorts as if it were a single character that appears between the characters 's'
and 't'. According to these rules, for example, the word "sort" is alphabetized
ahead of the word "short", even though the character 'o' appears after 'h' in
the alphabet.
Implement a class LocalSort that contains a method sort for alphabetizing
String objects according to the rules above.
DEFINITION
Class name: LocalSort
Method name: sort
Parameters: String[]
Return type: String[]
Method signature (be sure your method is public): String[] sort(String[]
strings);
Argument strings contain the String objects to be sorted. Your method should
return a String[] sorted according to the alphabetization rules described above.
TopCoder will ensure the validity of the inputs. Inputs are valid if all of
the following criteria are met:
- strings contains 0 to 50 elements, inclusive.
- Each string is 0 to 50 characters in length, inclusive.
- Each string is composed of lowercase characters in the range from 'a' to 'z',
inclusive; no digits or special characters are allowed.
EXAMPLES
- if strings={"sorted", "sort"}, your method should return {"sort", "sorted"}
- if strings={"shorted", "short"}, your method should return {"short", "shorted"}
- if strings={"short", "sorted"}, your method should return {"sorted", "short"}
- if strings={"ssh", "ssz", "so", "sch", "csh", "ash", "sh", "ach", "asz",
"acz", "aczh", "aszh", "aach", "aash", "aacz"}, your method should return
{"aacz", "aach", "aash", "acz", "aczh", "ach", "asz", "aszh", "ash", "csh",
"sch", "so", "ssz", "ssh", "sh"}
- if strings={}, your method should return {}