Sorting string with if-else
Your indentation is off. if should be at the same level as the corresponding else or else if, their bodies being indented once. Don't wander all the way to the right.

You are missing the include for std::string, &lt;string&gt;.

using namespace std; seems convenient, right? Unfortunately, throwing everything and the kitchen sink into the global namespace and praying it works is error-prone.
See &quot;Why is “using namespace std;” considered bad practice?&quot;.
I wouldn't even use a using-declaration here, though that would be unproblematic at least.

return 0; is implicit for main(). (And only for that function.)

You never test whether reading (and/or writing) succeeds. At least that's pretty harmless in your program. Still, consider ending with:
    return !!std::cin || !!std::cout;


Swapping is often far more efficient than copying. Consider using a.swap(b) or the more generic using std::swap; swap(a, b); two-step, the latter is in &lt;utility&gt;.

Only use std::endl when you need to flush the stream. Actually, belay that, be explicit and use std::flush.
Hint: std::cin and std::cout are tied, which you already take advantage of with your prompt. Also, when the program ends the standard streams are flushed.
See &quot;What is the C++ iostream endl fiasco?&quot;.

Comparing strings is likely to be comparatively expensive. Thus, compare two strings, and then make different decisions depending on the outcome.

An alternative to considering each case separately is writing a sorting-network.
You would be well-advised to abstract a conditional swap into its own function if you go that way:
void sort2(std::string&amp; a, std::string&amp; b) noexcept {
    if (b &lt; a)
        b.swap(a);
}