how to sort string aray in ts
// TypeScript
const value = ['2020', '2017', '2019', '2018']
value.sort((a,b) => a < b ? -1 : a > b ? 1 : 0) // Ascending
value.sort((a,b) => a < b ? 1 : a > b ? -1 : 0) // descending
// javaScript
const value = ['2020', '2017', '2019', '2018']
Array.from(value).sort((a,b) => a-b) // Ascending
Array.from(value).sort((a,b) => b-a) // descending
Also in JavaScript:
- react countup with visibility senor
- dynamodb pagination nodejs
- nuxt vuetify google fonts
- multiple line string in jquery
- Supported by YAML but not supported by JSON:
- detect close tab javascript
- les fonctions reguliere javascript
- regular expression not to allow space in javascript
- angular for each
- js data object length
- ionic status bar color
- react yup password with number string and uppercase
- first letter capital in javascript
- javascript in jsx
- dropdown using ajax and django
- lf will be replaced by crlf in package.json
- mat-drawer angular "10"
- generate component with module angular 8
- loop through object jquery
- does string contain special charactors javascript
- redux http library
- how to set text for label in jquery
- javascript reserved words
- js percorrer objeto