Last active
December 16, 2018 17:46
-
-
Save alexandersazonof/6fa33e8ddcbed99f281f171737968d15 to your computer and use it in GitHub Desktop.
This file contains 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
#Дана строка в которой записаны слова через пробел. Необходимо упорядочить слова по количеству букв в каждом слове. | |
str = "Alexander Yan Dasha Mari 1 s 123 1231 2124" | |
array = str.split.sort_by(&:length).join " " | |
puts array |
Author
alexandersazonof
commented
Dec 2, 2018
•
Саша, отлично!
Еще момент, лучше, чтобы было однообразное применение конструкций языка, если при вызове метода ты ставишь скобки, тогда ставь везде!
array = str.split.sort_by(&:length).join(" ")
🥇
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment