Sort the words , smallest to the longest

The function helps us sort the words that are smallest to the longest length in string…

function findLongestWordLength(str) {
  let regex = /\w+([^w\s]+\w+)|\w+/g;
  let result = str.match(regex);
  for (let i = 1; i < result.length; i++) {
    for (let j = 0; j < result.length; j++) {
      if (result[i].length < result[j].length) {
        let temp = result[i];
        result[i] = result[j];
        result[j] = temp;
  return result;

    "What if we try a super-long word such as otorhinolaryngology"

//Output is :[“a”, “we”, “if”, “as”, “try”, “word”, “such”, “What”, “super-long”, “otorhinolaryngology”]

Hey @cihatsaman,

Do you have any trouble with the code? Is this a challenge? Or is this just a function you made and you want to share? Please explain further so we might be able to help you if you do need help…

Additional challenge: Sort them not only by length but also alphabetically. In other words, all words of the same length should be sorted alphabetically within their group.