Skip to content

Files

Latest commit

24c550b · Jan 9, 2021

History

History
This branch is 12 commits ahead of Dylan-Israel/100AlgorithmsChallenge:master.

sortByLength

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Jun 21, 2018
Jan 9, 2021
Jan 9, 2021

Check Out My YouTube Channel

Algorithm Challenge Available At CodeFights

Given an array of strings, sort them in the order of increasing lengths. If two strings have the same length, their relative order must be the same as in the initial array.

Example

For

inputArray = ["abc", "", "aaa", "a", "zz"]

the output should be

sortByLength(inputArray) = ["", "a", "zz", "abc", "aaa"]

Hints

  • sort()

Input/Output

  • [execution time limit] 5 seconds (ts)
  • [input] array.string inputArray

A non-empty array of strings.

Guaranteed constraints:

3 ≤ inputArray.length ≤ 10, 0 ≤ inputArray[i].length ≤ 10.

[output] array.string