Hi, I'm wondering why this piece of code isn't sorting and this is the same algorithm i've used before to sort a string of arrays. It runs and compiles but after it does so it gives me a error that my program has stopped working o_O.
My class is
1 2 3 4 5 6 7 8 9
class Student {
public:
string name;
int score1;
int score2;
int score3;
int total_score;
string score_status;
};
Here is my function to sort the array. I have yet to begin to carry along all the information in the object. I'm a bit confused as where to go after this:
You should find something better than a bubble sort.
In any case, to sort a list of things, you must exchange the entire thing, not just part of it. What your swap (lines 10 through 12) does is just cheat the better-scoring student by moving his name onto a poorly-performing student's scores.