mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-29 12:49:05 +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(); });
|
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; });
|
quick_sort(processes, [](auto& a, auto& b) { return a.pid < b.pid; });
|
||||||
|
}
|
||||||
|
|
||||||
Vector<Vector<String>> rows;
|
Vector<Vector<String>> rows;
|
||||||
rows.ensure_capacity(1 + processes.size());
|
rows.ensure_capacity(1 + processes.size());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue