Skip to content

Instantly share code, notes, and snippets.

@larscmagnusson
Created October 19, 2022 06:07
Show Gist options
  • Save larscmagnusson/837d1477e6df30c8038e21c687325b92 to your computer and use it in GitHub Desktop.
Save larscmagnusson/837d1477e6df30c8038e21c687325b92 to your computer and use it in GitHub Desktop.
Sort unsorted list
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