sort an array by size code example
Example: sort array by string length javascript
function sortByLength(arr) {
return arr.sort((x,y) => x.length - y.length);
}
function sortByLength(arr) {
return arr.sort((x,y) => x.length - y.length);
}