If i have 2 array contains data

1 50
2 30
3 40
4 70


if I want to sort in descending order which take nombor and data together...

4 70
1 50
3 40
2 30

How???

Recommended Answers

All 2 Replies

When you exchange one array during the sort you have to make similar exchanges in the second array. That's one reason that many (most?) programmers put suich things in an array of structures -- to make sorting a lot simpler.

struct data
{
    int a;
    int b;
};

Now instead of sorting two arrays you only have to sort one array of structures.

If I put like this???

struct exam
{
string examid;
vector <int> total;
};
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.