Created
January 5, 2019 12:06
-
-
Save deHelden/6932bb122ee7c521483b6a776824a189 to your computer and use it in GitHub Desktop.
[Task 7] Sorts string by word's length
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 7) Дана строка в которой записаны слова через пробел. Необходимо упорядочить | |
# слова по количеству букв в каждом слове. | |
def sort_string_by_words_length | |
string = "alskdfj asd;lfjk asdkfj;lasd flaskdj f as;dlfjk a;sd fkla sdf;" | |
splitted = string.split | |
splitted.sort_by(&:length) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment