The function either rearranges the characters in the input string or keeps them the same.
