Check for length and produce new string with specific order