You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
14 lines
314 B
Markdown
14 lines
314 B
Markdown
# Sort list of strings in Javascript
|
|
|
|
[source](https://stackoverflow.com/questions/6712034/sort-array-by-firstname-alphabetically-in-javascript)
|
|
|
|
```ts
|
|
users.sort((a, b) => a.firstname.localeCompare(b.firstname))
|
|
```
|
|
|
|
or reversed order:
|
|
|
|
```ts
|
|
users.sort((a, b) => a.firstname.localeCompare(b.firstname) * -1)
|
|
```
|