Created
October 19, 2022 06:07
-
-
Save larscmagnusson/837d1477e6df30c8038e21c687325b92 to your computer and use it in GitHub Desktop.
Sort unsorted list
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const unsortedString = ` | |
a | |
c | |
b | |
` | |
const sortedString = [...unsortedString.split('\n')] | |
.map(x => x.trim()) | |
.filter(x => x) | |
.sort() | |
.join('\n') | |
console.log(sortedString) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment