Hello. I am trying to create a program which will sort strings, input by the user, into alphabetical order. So for example, if the user inputs Henry, Derik, Steven, in that order, the output should be Derik, Henry, Steven. This is the code I have so far. Any help is appreciated.
Thanks kbw. Unfortunately, I'm relatively new to programming, so what you said makes very little sense to me. I don't know what a collection or a standard container is. I'm trying to get this to work as it is an exercise in my book, but I have been struggling with it for over two hours now. If it's not too much trouble, could you show me an example of how to create a basic sorting algorithm for strings?
Put the first two items in order.
Then the second and third. (At this point third item will be in its final place.)
Then the first two again. (Putting them in their final place.)
@Duoas:
Thanks for the directions, but that stuff makes no sense to me yet. I'm really trying to keep this as simple as possible. As for the trick, I'm probably doing it wrong, but it's still not working. Perhaps you could illustrate with some code?
@justinelandichoruiz:
Thanks for sharing your code. I ran some tests, using the letters 'a', 'b' and 'c' for control. These are the results I got back:
As far as I can see every input works correctly except for when:
val1 > val2 && val1 < val3
and
val1 > val2 && val1 > val3
I find it strange that a respective input of b, a and c results in two empty output spaces, and that a respective input of c, a and b results in three empty output spaces. Any ideas?