Sort the words in a given sentence

Note: This problem needs knowledge of topics you haven't covered yet. Reading List

Problem Statement

Create a method named 'sort_string' which accepts a String and rearranges all the words in ascending order, by length. Let's not treat the punctuation marks any different than other characters and assume that we will always have single space to separate the words.

Example: Given a string "Sort words in a sentence", it should return "a in Sort words sentence".

Note: You can use the sort method to sort an array. Try the documentation at ruby-lang to know more about sort.

Output Window


Reading list for this problem

You are yet to work on:

Congratulations, guest!


% of the book completed

or