Lets do it step by step. Firstly, do you have any understanding of how sorting could be done. If, for example, you had an array int my_array[10] = {1, 5, 7, 6, 2, 3, 4, 9, 10, 8};, would you be able to sort that? If no, google "bubble sort". Wikipedia has plenty of pseudo code and if you're too lazy for that, I'm sure you could find yourself an example C++ implementation.
You're not going to get anywhere if you try to do everything at the same time. It's obvious that this algorithm can be implemented as in my first post. Just try doing it on paper. And now, bubble sort isn't useless any more.
Writing a spiral could be more tricky. I suggest writing a function that puts the numbers on the outermost ring (using four for loops) and then calls itself for the inner ones. Example:
* * * 1 2 * 1 2 3 1 2 3 1 2 3
* * * => * * * => * * 4 => * * 4 => 8 * 4
* * * * * * * * * * 6 5 7 6 5
and finally recursively call the same function for the inner * (maybe I should have used a bigger matrix for an example..)
* => 9