C++

#include<string>
#include<algorithm>
using namespace std;
#define MAX 100
struct Mouse {
	int w;//重量
	string cap;//帽子颜色
}m[MAX+1];
bool CMP(Mouse a,Mouse b) {
	
	return a.w>b.w;
}
int main() {
	int N;
	while (cin >> N) {
		for (int i = 0; i < N; i++) {
			cin >> m[i].w >> m[i].cap;
		}
		sort(m, m + N, CMP);
		for (int i = 0; i < N; i++) {
			cout << m[i].cap << endl;
		}
	}

	return 0;
}