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)?