Ordene um array pelo comprimento das strings

Published by Matt in

Crie uma função que receba um array de strings e retorne um array ordenado da string mais curta para a mais longa.

Exemplos

sort_by_length(["Google", "Apple", "Microsoft"])
➞ ["Apple", "Google", "Microsoft"]

sort_by_length(["Leonardo", "Michelangelo", "Raphael", "Donatello"])
➞ ["Raphael", "Leonardo", "Donatello", "Michelangelo"]

sort_by_length(["Turing", "Einstein", "Jung"])
➞ ["Jung", "Turing", "Einstein"]

Observações

Todos os casos de teste contêm arrays com strings de comprimentos diferentes, então você não terá que lidar com várias strings com o mesmo comprimento.