785 B
785 B
30 seconds of code
Curated collection of useful Javascript snippets that you can understand in 30 seconds or less.
- Use Ctrl + F or command + F to search for a snippet.
- Contributions welcome, please read contribution guide.
Sort characters in string (alphabetical)
Split the string using split(''), sort() utilizing localeCompare(), recombine using join('').
var sortCharactersInString = str =>
str.split('').sort( (a,b) => a.localeCompare(b) ).join('');
Credits
Icons made by Smashicons from www.flaticon.com is licensed by CC 3.0 BY.
