Last active
November 27, 2018 13:00
-
-
Save mikalai-yankouski/b272d6f7c84a1b0aec8f2970b4f50065 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
require 'faker' | |
random_string = Faker::Lorem.words(10).join(" ") #Faker возвращает array, поэтому join в строку | |
sorted_string = random_string.split.sort {|x,y| x.length <=> y.length} | |
puts "String: #{random_string.inspect}" | |
puts "Sorted string: #{sorted_string}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment