Please help - sorting integers in structs

Posted by maja k. on Stack Overflow See other posts from Stack Overflow or by maja k.
Published on 2010-06-07T14:48:35Z Indexed on 2010/06/07 14:52 UTC
Read the original article Hit count: 293

Filed under:
|
|
|

I have a struct like this:

struct db {
 string name,sur;
 int num;
};

And declared an array of db structs:

struct db a[10];

and every member of a[] is filled with a name, surname and a number but there can be the same number appearing multiple times. I need to sort the numbers, and print the results, i.e. sort by the num of each struct and the print the name, sur and the num in each line starting from the smallest num going down to the largest. I don't know how to do this, please help me.

© Stack Overflow or respective owner

Related posts about c++

Related posts about sorting