Day 6 is how to sort an array that has different length of value.
This is helpful to sort name based on length of the name in the array by using sort
method.
For instance an array ['Samuel','Jon','Karra','Hery']
sorted into ['Jon','Hery','Karra','Samuel']
This is JavaScript solution
function sortByLength(strs) {
return strs.sort((a,b) => a.length - b.length);
}
Top comments (0)