Hi I am hoping someone might be able to help with with a quick question. I am working on a problem on paper as I am not near a computer, so I can not test what I am about to ask.
If I get input from a user as strings, and each string I pass it to a vector. Can I call sort() on the vector to put the strings into alphabetical order?
I've just recently became familiar with the sort function etc, so was not sure if it works the same way with strings as it does with integers. But now I know, thank you for the help
The STL (containers, iterators, algorithms, functions) was designed to work generically on any built-in type and with any user-defined type that supports some elementary operations (such as copying and assignment).
In a rough nutshell:
While std::basic_string isn't part of the STL, it has been designed to work with the STL algorithms and functions.
If it has a < operator (and is movable), you can use it with std::sort. If it doesn't have a < operator (but is still movable), then you can still use it with std::sort, but you'll need to pass it a binary predicate that it can use to sort your stuff.