Sortuj tablicę numeru JavaScript z duplikatami
//ascending order
console.log([1, 2, 0, 1].sort((a, b) => a - b))
//descending order
console.log([1, 2, 0, 1].sort((a, b) => b - a))
Run code snippetHide results
Yasser Friha