Swap, anagrams, occurences

Fixed sorting title for strings.
This commit is contained in:
Angelos Chalaris
2017-12-06 23:50:23 +02:00
parent 91c257ec38
commit 3321bf9e22
5 changed files with 67 additions and 1 deletions

View File

@ -0,0 +1,8 @@
### Sort characters in string (alphabetical)
Split the string using `split('')`, `sort()` utilizing `localeCompare()`, recombine using `join('')`.
```js
var sortCharactersInString = str =>
str.split('').sort( (a,b) => a.localeCompare(b) ).join('');
```