This question takes me back to when we would ask to stand in a heightwise order in the morning assembly at our school. Starting form the first student, if the next person was taller than the first student, all was bueno. But if the next person was shorter, they would come to the beginning of the line. And then the line would be considered skipping that person, and counting only from the second-in-line, so we don't keep re-sorting the already sorted.
I have attempted to understand and demonstrate a similar simple code in C++. Except here, numbers replace the student. Yet another exmaple of machines taking over
In your terminal of choice, navigate to teh directory where the file is stored and run the following:
$ g++ basic_sort.cpp
$ ./a.out