Consider these strings (quotes for clarity, they're not part of the strings).
{"apple", "pear", "cherry", "apple", "pear", "apple", "banana"}
The array returned is:
{ "apple", "pear", "banana", "cherry" }
since the most frequently occurring string is
"apple" which occurs 3 times; the string
"pear"
occurs twice and the other strings each occur once so they are
returned in alphabetical order.
String[]
String[]
String[] sort(String[] data)(be sure your method is public)
data = {"apple", "pear", "cherry", "apple", "pear", "apple", "banana"}
Returns: {"apple", "pear", "banana", "cherry" }
This is the example given above.
data = {"a","b","c",d"}
Returns: {"a","b","c",d"}
data = {"d","c","b","a"}
Returns: {"a","b","c",d"}
Same as previous, each occurs once ties are broken alphabetically.
data = {"a","a","a"}
Returns {"a"}