#include<vector>
#include<algorithm>
#define NUM 10
using namespace std;
vector<int> values;
bool cmd1(int a, int b) {
if (values[a] < values[b])
return true;
return false;
}
void main() {
vector<int> keys;
for (int i = 0; i < NUM; i++) {
keys.push_back(i);
values.push_back(rand() % 30);
}
//集合keys每个键根据values中每个值进行升序排序
sort(keys.begin(), keys.end(), cmd1);
for (int i = 0; i < NUM; i++) {
printf("key : %d,value : %d\n", keys[i],values[keys[i]]);
}
system("pause");
}