private sumArray : any = [];
private sortedArray : any = [];
private arr1 =['3','2','1'];
private arr2 = ['5','7','9','8'];
constructor(){}
ngOnInit(){
this.sumArray = this.arr1.concat(this.arr2);
this.sortedArray = this.sumArray.sort((a, b) => parseInt(b) - parseInt(a));
}
Looking for a way to sort an array in descending order using TypeScript in Angular version 2 or higher? Check out the complete code here!