Problem Statement
Example:
"The big, brown dog ran down the street!"Returns:
"The big, brown dog down ran street the!"Observe the space and punctuation preservation between the original sentence and the resulting sentence.
Definition
- Class:
- SuperSort
- Method:
- wordSort
- Parameters:
- String
- Returns:
- String
- Method signature:
- String wordSort(String sentence)
- (be sure your method is public)
Notes
- Watch out for multiple consecutive spaces (they should be preserved).
Constraints
- sentence will contain between 1 and 50 characters, inclusive.
- Each character in sentence will be either a letter ('a'-'z', 'A'-'Z'), ' ', '.', ',', '!' or '?'.
Examples
"The big, brown dog ran down the street!"
Returns: "The big, brown dog down ran street the!"
"This is the first sentence of the paragraph."
Returns: "This first is of paragraph sentence the the."
"t.d,a!f?g.b,q!i?p.h,s!u?m.l,e!v?y.c,j!w?k.n,x!o?r."
Returns: "a.b,c!d?e.f,g!h?i.j,k!l?m.n,o!p?q.r,s!t?u.v,w!x?y."
"What is this?"
Returns: "What is this?"
"? . , ! "
Returns: "? . , ! "
" "
Returns: " "
"faecdb"
Returns: "faecdb"
"a A b B c C d D e E"
Returns: "A B C D E a b c d e"
".a."
Returns: ".a."
" bb "
Returns: " bb "
" . ? .bcb"
Returns: " . ? .bcb"
"z.yy.xxx...ww.uuuu tt"
Returns: "tt.uuuu.ww...xxx.yy z"
"aA Aa bB Bb.? !.Cc cC"
Returns: "Aa Bb Cc aA.? !.bB cC"
".The The.The,The?The!The"
Returns: ".The The.The,The?The!The"
".., ??!. ,,, , "
Returns: ".., ??!. ,,, , "
"a . b c e f , ! g ? g"
Returns: "a . b c e f , ! g ? g"
".d....ef......ag...adf....d...sd..f."
Returns: ".adf....ag......d...d....ef...f..sd."
"defg cdef bcde abde.edba edcb fedc gfed"
Returns: "abde bcde cdef defg.edba edcb fedc gfed"
"defg cdef bcde abde.edba edcb fedc gfed"
Returns: "abde bcde cdef defg.edba edcb fedc gfed"
" z.w!xx,,,yy aaaaa fffff adslfjasdf fdjla"
Returns: " aaaaa.adslfjasdf!fdjla,,,fffff w xx yy z"
"jkld,ajkfla,,,fkaldfjkal,,a,dd..adsf.fjdl..adsfa.a"
Returns: "a,a,,,adsf,,adsfa,ajkfla..dd.fjdl..fkaldfjkal.jkld"
"lk kld adf jkl, adsf. adsf! fjdkls? alsdfj ?adfj??"
Returns: "adf adfj adsf adsf, alsdfj. fjdkls! jkl? kld ?lk??"
"ZZw,!ZZt ZZr,,ZZm!!ZZl . ZZj??ZZk ZZc"
Returns: "ZZc,!ZZj ZZk,,ZZl!!ZZm . ZZr??ZZt ZZw"
"czzz.bbbbbbbbbb.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
Returns: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.bbbbbbbbbb.czzz"
"Able, Alex abhors aggression!"
Returns: "Able, Alex abhors aggression!"
" A"
Returns: " A"
"A..............................."
Returns: "A..............................."
".AA. ,CCC, !FFFFF! ?AAA?"
Returns: ".AA. ,AAA, !CCC! ?FFFFF?"
"B!!!!!!!!!!!!!!!!!!!!!!!A"
Returns: "A!!!!!!!!!!!!!!!!!!!!!!!B"
"....vv..A A,,XX,,,,"
Returns: "....A..A XX,,vv,,,,"
"?What did the old man say"
Returns: "?What did man old say the"
"a"
Returns: "a"
"."
Returns: "."
"a,a"
Returns: "a,a"
"q"
Returns: "q"
"? af . , A ! df "
Returns: "? A . , af ! df "
"hvala"
Returns: "hvala"
" a b c d e f g h i j k l m n o p q r s t u v w x y"
Returns: " a b c d e f g h i j k l m n o p q r s t u v w x y"
" !ss!!b ! !"
Returns: " !b!!ss ! !"
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
Returns: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
" !! t h Tes a Word"
Returns: " !! Tes Word a h t"