Page MenuHomePhabricator

Stable sort project tags in query results
Closed, ResolvedPublic

Description

When listing several tasks with the same tags having the latter not consistently ordered increases the visual noise and makes it harder to spot differences.

Event Timeline

em created this task.Aug 3 2016, 9:23 AM
chad renamed this task from Stable sort project tags in Maniphest query results to Stable sort project tags in query results.Aug 3 2016, 1:41 PM
chad edited projects, added Projects; removed Maniphest.

I don't think this is a sort stability issue: we're preserving the order which the user who entered the tags originally used (in this particular UI it looks like we actually use reverse order, which I'd consider a bug, but other UIs like the "Tags" in the rightmost column and when editing the tags via "Edit Task" we use the original order).

Being order-preserving seems slightly more useful to me than sorting? Especially in cases like editing (all the stuff is where you put it) and analogous cases like Subscribers (later users joined later). I'll fix the display order, though.

em added a comment.Aug 3 2016, 3:20 PM

Ah, I didn't even notice there was a sorting criterion.

Personally I find myself wondering if I applied all the right tags to a set of tasks quite often, and so far I never used the list of tags to understand the history of how they were assigned. In other words, what I care about is that the current set is correct (which is easier to visually check if tags are sorted), not that they got assigned in the right order.

In general I see that list of tags as purely information about the current state of the task, no matter how it got there, as preserving their chronological order would still miss a lot of interesting chronological information (tags deleted, tags deleted and then re-added).

Honestly I don't see much value in keeping subscribers chronologically sorted either, but that didn't impact me much. :)

D16367 make the order consistent (instead of reversed) in the task list view and on workboard cards.

I don't plan to make a change to order by name. You could apply this patch (or some similar patch) locally if you want that behavior:

diff --git a/src/applications/phid/view/PHUIHandleTagListView.php b/src/applications/phid/view/PHUIHandleTagListView.php
index eb909d4..dddbc98 100644
--- a/src/applications/phid/view/PHUIHandleTagListView.php
+++ b/src/applications/phid/view/PHUIHandleTagListView.php
@@ -61,6 +61,11 @@ final class PHUIHandleTagListView extends AphrontTagView {
       }
     }
 
+    if (!is_array($handles)) {
+      $handles = iterator_to_array($handles);
+    }
+    $handles = msort($handles, 'getName');
+
     if ($this->limit && (count($handles) > $this->limit)) {
       if (!is_array($handles)) {
         $handles = iterator_to_array($handles);
em added a comment.Aug 9 2016, 3:54 PM

Thanks, the patch definitely helps a lot in my case!