← Back to challenges

Sort the String

JavaScriptHardsortingstringsalgorithms

Instructions

Create a function that takes a string consisting of lowercase letters, uppercase letters and numbers and returns the string sorted in the same way as the examples below.

Examples

sorting("eA2a1E") ➞ "aAeE12"
// Don't repeat letters.

sorting("Re4r") ➞ "erR4"

sorting("6jnM31Q") ➞ "jMnQ136"

sorting("846ZIbo") ➞ "bIoZ468"

Notes

Don't repeat letters (numbers can be repeated).

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.