koehr.ing/til/2024-05-12.md
2024-05-12 20:15:27 +02:00

314 B

Sort list of strings in Javascript

source

users.sort((a, b) => a.firstname.localeCompare(b.firstname))

or reversed order:

users.sort((a, b) => a.firstname.localeCompare(b.firstname) * -1)