Archive, multitagging, cleanup
Cleaned up the current snippets for consistency and minor problems, added multiple tags to most of them, archived a few.
This commit is contained in:
@ -2,12 +2,11 @@
|
||||
|
||||
Alphabetically sorts the characters in a string.
|
||||
|
||||
Split the string using `split('')`, `Array.sort()` utilizing `localeCompare()`, recombine using `join('')`.
|
||||
Use the spread operator (`...`), `Array.sort()` and `String.localeCompare()` to sort the characters in `str`, recombine using `String.join('')`.
|
||||
|
||||
```js
|
||||
const sortCharactersInString = str =>
|
||||
str
|
||||
.split('')
|
||||
[...str]
|
||||
.sort((a, b) => a.localeCompare(b))
|
||||
.join('');
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user