mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:37:44 +00:00
ps: Sort using input order in case of -q
Now the output of `ps -q <list>` is sorted according to the order the user specified.
This commit is contained in:
parent
259ecb3d11
commit
ac7c83689b
1 changed files with 7 additions and 2 deletions
|
@ -110,9 +110,14 @@ int main(int argc, char** argv)
|
|||
}
|
||||
|
||||
processes.remove_all_matching([&](auto& a) { return selected_pids.find(a.pid) == selected_pids.end(); });
|
||||
}
|
||||
|
||||
auto processes_sort_predicate = [&selected_pids](auto& a, auto& b) {
|
||||
return selected_pids.find_first_index(a.pid).value() < selected_pids.find_first_index(b.pid).value();
|
||||
};
|
||||
quick_sort(processes, processes_sort_predicate);
|
||||
} else {
|
||||
quick_sort(processes, [](auto& a, auto& b) { return a.pid < b.pid; });
|
||||
}
|
||||
|
||||
Vector<Vector<String>> rows;
|
||||
rows.ensure_capacity(1 + processes.size());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue