Visitar URL original
Sort in decreasing order
The Wayback Machine - https://web.archive.org/web/20240829124254/https://javascript.info/task/sort-back

We want to make this open-source project available for people all around the world.

Help to translate the content of this tutorial to your language!

back to the lesson

Sort in decreasing order

importance: 4
let arr = [5, 2, 1, -10, 8];

// ... your code to sort it in decreasing order

alert( arr ); // 8, 5, 2, 1, -10
let arr = [5, 2, 1, -10, 8];

arr.sort((a, b) => b - a);

alert( arr );