W3CSchools has this example:
var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.sort();
fruits.reverse();
Is this the most efficient way to sort strings in descending order in Javascript?
Update
One of the answers is using localeCompare. Just curious whether if we do reverse(), will that work for all locales (Maybe this is a separate question - Just let me know in the comments)?
.sort()and.reverse()is already the most efficient way..sort((a, b) => -(a>b)||+(a<b))reverse()doesn't care about the locales, it only modifies the indexes of the array in reverse order