按级别排好序,先排消耗时间,相同排日期,再相同排时刻

#include <iostream>
#include <algorithm>
#include <sstream>
using namespace std;

const int N = 10010;

struct record {
    string name;    // 日志名称
    string date;    // 年月日
    string start_time;  // 时分秒
    double task_time;   // 消耗时间
    string line;
}a[N];

// 按消耗时间升序排列,如果时间相同按时间顺序排序,按级别排好序
bool cmp(const record &a, const record &b) {
    if (a.task_time < b.task_time) {
        return true;
    }
    else if (a.task_time == b.task_time && a.date < b.date) {
        return true;
    }
    else if (a.task_time == b.task_time && a.date == b.date && a.start_time < b.start_time) {
        return true;
    }
    else {
        return false;
    }
}

// bool cmp(record &a, record &b) {
//     if (a.task_time != b.task_time) {
//         return a.task_time < b.task_time;
//     }
//     else {
//         if (a.date != b.date) {
//             return a.date < b.date;
//         }
//         else {
//             return a.start_time < b.start_time;
//         }
//     }
// }

int main() {
    string line;
    int i = 0;
    while (getline(cin, line)) {
        a[i].line = line;
        stringstream ssin(line);
        ssin >> a[i].name >> a[i].date >> a[i].start_time >> a[i].task_time; // 不用管类型,ssin>>读入即可
        i++;
    }
    sort(a, a + i, cmp);
    for (int j = 0; j < i; j++) {
        cout << a[j].line << endl;
    }
    return 0;
}