mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-28 04:09:00 +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
Notes:
sideshowbarker
2024-07-18 05:09:41 +09:00
Author: https://github.com/i3abghany
Commit: ac7c83689b
Pull-request: https://github.com/SerenityOS/serenity/pull/9632
Reviewed-by: https://github.com/alimpfard
Reviewed-by: https://github.com/sin-ack ✅
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(); });
|
||||
}
|
||||
|
||||
quick_sort(processes, [](auto& a, auto& b) { return a.pid < b.pid; });
|
||||
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