Swap, anagrams, occurences

Fixed sorting title for strings.
This commit is contained in:
Angelos Chalaris
2017-12-06 23:50:23 +02:00
parent e86bf2ffa3
commit f40115ff3b
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('');
```