I'd like to write code using class double sorting(?).
For example, class has three data member i.e. num
, error
, and data
.
class Test
{
public:
int num;
float error;
vector<float> data;
};
Now, I make:
vector<Test> TestList;
and, those have:
TestList[0] : num = 1, error = 0.001, data0
TestList[1] : num = 1, error = 0.01, data1
TestList[2] : num = 2, error = 0.01, data2
TestList[3] : num = 3, error = 0.001, data3
TestList[4] : num = 3, error = 0.01, data4
Then, I want to sort them with num
(higher priority) and error
.
The expected result is the TestList
is arranged as following order:
Test[4] : num = 3, error = 0.001, data4
Test[3] : num = 3, error = 0.01, data3
Test[2] : num = 2, error = 0.01, data2
Test[0] : num = 1, error = 0.001, data0
Test[1] : num = 1, error = 0.01, data1
How can I do this? In addition, how can I call this algorithm?