Try   HackMD

Uppercase to the Front, Lowercase to the Back


If you're viewing this on the Challenge Zone website, you can click here to open the challenge in a new tab.

Scanerio

In the land of Captial, all sentences are written in an unorthox way where capitalized letters have priority over lowercase letters. Due to this, all essays, poems, articles, books and other written texts are published with all capital letters in a word or sentence placed at the beginning of the text.

Task

Your task is to create a function organizedString which accepts a String argument and moves all capital letters to the front of the string while maintaining the original order of letters.


organizedString

The organizedString function should only accept a String argument and is expected to return a String containing the newly organized string.


Sample Results

organizedString("mOvEMenT") // --> OEMTmven organizedString("fortKNOX") // --> KNOXfort organizedString("uniTEDSTAtes") // --> TEDSTAunites organizedString("") // --> "" (Empty String) organizedString("HELLOworld") // HELLOworld (No change necessary) organizedString("harry WAShisnam E") // WASEharryhisnam

Explanation

In the first example, the uppercase letters from the String 'mOvEMent' are 'OEMT'. These letters will now be reorganized and placed at the front of our string while maintaining the original sequence of letters, followed by the lowercase letters 'mven', which maintains the original sequence of letters.


Your function should work for any String argument. DO NOT HARDCODE!