How to sort an array of strings in descending order with JavaScript

1 Answer

0 votes
const array = ["php", "c", "python", "c++", "javascript"];
 
array.sort();
array.reverse();
 
console.log(array);
 
       
     
/*
run:
     
["python", "php", "javascript", "c++", "c"] 
     
*/

 



answered Mar 28, 2021 by avibootz
...