Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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
Comment

PREVIOUS NEXT
Code Example
Javascript :: js number remove last 2 characters 
Javascript :: await async sleep 
Javascript :: jquery datepicker no past dates 
Javascript :: chart js hide legend 
Javascript :: brain.js cdn 
Javascript :: javascript get current time 
Javascript :: kill all node process ubunut 
Javascript :: jquery check scroll direction 
Javascript :: change id in jquery 
Javascript :: get browser language 
Javascript :: $(...).autocomplete is not a function 
Javascript :: javascript location href target _blank 
Javascript :: js for each element class 
Javascript :: js how to shufle elements in array 
Javascript :: aws s3 cors configuration json example 
Javascript :: how express serve public folder 
Javascript :: select a label from jquery using for attribute 
Javascript :: axios delete is throwing cors error 
Javascript :: javascript remove last characters from string 
Javascript :: create element ns svg 
Javascript :: cdn opencv.js 
Javascript :: javascript reduce function to get sum of object value 
Javascript :: items in center in native 
Javascript :: node js delete folder with files 
Javascript :: window.href 
Javascript :: javascript loop FormData 
Javascript :: datatable default sorting 
Javascript :: find label jquery 
Javascript :: console group 
Javascript :: javascript detect enter press on input 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =