Fully renamed and updated everything, tagged, built
This commit is contained in:
11
snippets/sortCharactersInString.md
Normal file
11
snippets/sortCharactersInString.md
Normal file
@ -0,0 +1,11 @@
|
||||
### sortCharactersInString
|
||||
|
||||
Alphabetically sorts the characters in a string.
|
||||
|
||||
Split the string using `split('')`, `Array.sort()` utilizing `localeCompare()`, recombine using `join('')`.
|
||||
|
||||
```js
|
||||
const sortCharactersInString = str =>
|
||||
str.split('').sort((a, b) => a.localeCompare(b)).join('');
|
||||
// sortCharactersInString('cabbage') -> 'aabbceg'
|
||||
```
|
||||
Reference in New Issue
Block a user