diff --git a/local/pkgs/hpcstat/src/sql.cpp b/local/pkgs/hpcstat/src/sql.cpp index 3b4d5c02..c8b50950 100644 --- a/local/pkgs/hpcstat/src/sql.cpp +++ b/local/pkgs/hpcstat/src/sql.cpp @@ -262,7 +262,16 @@ namespace hpcstat::sql // export to markdown std::cout << "| 账号 | 使用核时 | 登陆次数(交互式) | 登陆次数(非交互式) | 成功任务数 | 失败任务数 | SSH密钥编号::指纹 |\n"; std::cout << "| :--: | :--: | :--: | :--: | :--: | :--: | :--: |\n"; - for (auto& [key, stat] : stat_account) + std::vector, StatAccount>> stat_account_vector + (stat_account.begin(), stat_account.end()); + auto compare = [](auto& a, auto& b) + { + if (a.first) + { if (b.first) return Keys[*a.first].PubkeyFilename < Keys[*b.first].PubkeyFilename; else return true; } + else return false; + }; + std::sort(stat_account_vector.begin(), stat_account_vector.end(), compare); + for (auto& [key, stat] : stat_account_vector) std::cout << "| {} | {:.2f} | {} | {} | {} | {} | `{}::{}` |\n"_f ( key ? Keys[*key].Username : "(unknown)", stat.CpuTime, stat.LoginInteractive, stat.LoginNonInteractive,