Portfolio
Sort_Array_By_String_Length
/*Write a function that takes an array of strings as an argument and returns a sorted array containing the same
strings, ordered from shortest to longest.
For example, if this array were passed as an argument:
["Telescopes", "Glasses", "Eyes", "Monocles"]
Your function would return the following array:
["Eyes", "Glasses", "Monocles", "Telescopes"]
All of the strings in the array passed to your function will be different lengths, so you will not have to
decide how to order multiple strings of the same length.
*/
class Kata
{
public:
std::vector<std::string> sortByLength(std::vector<std::string> array)
{
std::sort(array.begin(), array.end(), [](const std::string &val1, const std::string &val2){
return val1.size()<val2.size();});
return array;
}
};
