I'm trying to sort a vector full of integers with Quick Sort, there are no errors, but after the sorting process the numbers are still in their original order. Code is here: http://pastebin.com/grxtR1wk Thanks
I'm guessing you want to write vector<int>& array. When you just write vector<int> array, you're creating a copy of the array every time you call QuickSort.
You appear to be only manipulating a copy of your array, your return is just an int. If you want to manipulate the actual array you will need to pass a pointer or put it inside your main where it has direct access to your array.
Yes that was the problem, and putting an "&" before "array" solved it. I wasn't aware it was that simple. Thanks guys :)
Amazing how the little things can thorw ya.. :) Glad you got it working.
Join our real-time social learning platform and learn together with your friends!