sort by lenght array nodejs code example
Example 1: sort array by string length javascript
function sortByLength(arr) {
return arr.sort((x,y) => x.length - y.length);
}
Example 2: javascript sorting array string by len
array.sort(function(a, b){return b.length - a.length});