Just trying to compile what you have written I immediately get 12 error.
You need to change the section prior to your main(). All the variables and loops need to be placed in main, or at the least in a function.
After deleting the loops and variable declarations etc as mentioned above and fixing a quick syntax error I have found a 'running' program.
The reason why you keep getting 9 is because 9 is the largest number in the array (you sorted it that way, ascending order). "For the most part", you have it correct. Just get rid of your cout in the middle of your for/while loop. Make a for-loop at the end of your program that outputs the array and you will find that you have an array with same elements but in ascending order.