This piece of code's purpose is to sort based on the second letter of a word. It worked when I passed using an array. However, it is not working with lists. Can anyone point me to the modification on where I can make it?
std::sort(std::begin(arr), std::end(arr),
[](std::string l, std::string r){
return l.substr(1) < r.substr(1);
}
);
std::cout << "Sorted List: " << std::endl;
for (auto const & s: arr) {
std::cout << s << std::endl;
}
std::cout << "The End" << std::endl;