Sorting vector via recursive functions

This is a discussion on Sorting vector via recursive functions within the C++ Programming forums, part of the General Programming Boards category; OK, so here is a basic for loop sorting function that I have coded prior to my current program:
Code:
...

It works, so I like it. However, with my current program, I would like to test the waters using recursive functions. Unfortunately, I have hit a brick wall and that's where I come to you all for help. Here is my class that I am using for this program:

in order to sort from max. to min. All help is appreciated!!! Thank you very much. If you would like to see my entire code in order to grasp, I will copy and paste it in as soon as I can. Thank you again!!!

You need to walk through the array and compare the elements. Whether you do this via recursion or loops doesn't really matter.

The general case for recursion is that you have a problem that is, under some circumstances is easy to solve, e.g. sorting two numbers is fairly easy - it's a compare and a swap. So how can you make your sort function perform a sort of just two numbers from a large vector?

well recursive functions are supposed to take a for loop and consolidate them down considerably to make it easier for the programmer and the program ultimately run a tad faster. so to optimize the speed of the program, I really want to know how to use recursive functions in order to sort through this vector. @ matsp, does this make sense? can you lay down a starting piece of code that would put me in the right direction please?! Thanks for the help!

well recursive functions are supposed to take a for loop and consolidate them down considerably to make it easier for the programmer and the program ultimately run a tad faster. so to optimize the speed of the program, I really want to know how to use recursive functions in order to sort through this vector. @ matsp, does this make sense? can you lay down a starting piece of code that would put me in the right direction please?! Thanks for the help!

oh, well regardless of the optimization, i would like to know how to turn this private member function into a recursive function. I want to test the waters, so I know how to do it if need be in the future. Thanks for the help!!! Here is what I have so far that needs to be converted:

You obviously will need to do SOMETHING to modify the numbers (at least sometimes) in your sort_down() function. How can you determine if the list is sorted? How can you determine if two elements need swapping.

If you want to learn how to use recursion, this is a very bad example to use it on, since trying to turn this sort function into a recursive function would almost certainly be MUCH more complicated and a LOT slower.

If you want a real example of a recursive algorithm, we can give you several, but I don't think anybody is going to spend any time on making a recursive bubble sort. Because of how bubble sort works, the recursion depth will be proportional to N and that makes it completely impractical for any real-world data set.

A more naturally recursive sorting algorithm would be merge sort or quick sort.

There are not different algorithm functions to call to sort ascending or descending. The SC++L determines the sort direction using comparison functors passed as an argument to std::sort.

std::sort sorts in place rather than returning a sorted copy.

Nope, I'm not buying that reason at all. If you want to know how it works, first learn how to use it and some of the theory behind it, then read the source code to it, and then try implementing it yourself.

You clearly have some other agenda. I'm thinking something along the lines of an assignment that states you must sort a vector using recursion, considering you're so hell bent on using recursion. What algorithm do you plan on using, and when is your assignment due?