Draft
Sort a sentence by words' length
Description:
Write a function sortByLength() that takes an array of strings and returns a two-dimensional array.
Each sub-array must regroup words of the same length. Their order must be the same as they appear in the input string.
The sub-arrays must be sorted by words' length, ascending.
sortByLength(['The', 'quick', 'brown', 'fox', 'jumps', 'over', 'the', 'lazy', 'dog'])
must return
[
[ 'The', 'fox', 'the', 'dog' ],
[ 'over', 'lazy' ],
[ 'quick', 'brown', 'jumps' ]
]
If the input is empty or not a string, return an empty array.
Strings will only contain words and spaces, so don't worry about punctuation.
Similar Kata:
Stats:
Created | Jan 12, 2022 |
Warriors Trained | 10 |
Total Skips | 0 |
Total Code Submissions | 17 |
Total Times Completed | 6 |
JavaScript Completions | 6 |
Total Stars | 0 |
% of votes with a positive feedback rating | 0% of 3 |
Total "Very Satisfied" Votes | 0 |
Total "Somewhat Satisfied" Votes | 0 |
Total "Not Satisfied" Votes | 3 |
Total Rank Assessments | 4 |
Average Assessed Rank | 7 kyu |
Highest Assessed Rank | 7 kyu |
Lowest Assessed Rank | 7 kyu |