Matriz de clasificación por longitud de cadena JavaScript
function sortByLength(arr) {
return arr.sort((x,y) => x.length - y.length);
}
Gorgeous Giraffe
function sortByLength(arr) {
return arr.sort((x,y) => x.length - y.length);
}
array.sort(function(a, b){return b.length - a.length});
(() => {
let arr = ["HTML", "Go", "Ruby", "Python", "JavaScript", "CSS"];
function sortByLength(arr) {
return arr.sort((a, b) => a.length - b.length);
}
console.log(sortByLength(arr)); // => [ 'Go', 'CSS', 'HTML', 'Ruby', 'Python', 'JavaScript' ]
})();