title: How to move all 'c' elements to the end with a recursive function using Kotlin?
body: <p>How can I write code that returns the following output for this input:</p>
  <p>Input:    -&gt;  fffcccfff<br />
  Output:   -&gt;  ffffffccc</p>
  <p>My code so far:</p>
  <pre><code>fun toEnd(s: String): String {
      if (s[0] == 'x') {
          return (s.substring(1)) + s[0]
      } else {
          return s[0] + toEnd(s.substring(1))
      }
  }
  </code></pre>
  <p>But that doesn't work for the input above.</p>