queue/Print: support sorting by priority

This commit is contained in:
Max Kellermann
2022-02-14 14:08:26 +01:00
parent 2172aaf1ce
commit ab5b6f83fd
4 changed files with 19 additions and 1 deletions

View File

@@ -143,6 +143,15 @@ PrintSortedQueue(Response &r, const Queue &queue,
return a.GetLastModified() < b.GetLastModified();
});
else if (sort == TagType(SORT_TAG_PRIO))
std::stable_sort(v.begin(), v.end(),
[&queue, descending](unsigned a_pos, unsigned b_pos){
if (descending)
std::swap(a_pos, b_pos);
return queue.GetPriorityAtPosition(a_pos) <
queue.GetPriorityAtPosition(b_pos);
});
else
std::stable_sort(v.begin(), v.end(),
[&queue, sort, descending](unsigned a_pos,