Community Health Toolkit

How are tasks ordered?

It is clear that Tasks are ordered by their “Due” date on the tasks tab, but from the documentation, it’s not clear how Tasks are ordered if there are multiple tasks with the same “Due” date.

  1. What is the sort algorithm for displaying tasks that have the same “Due” date?; and
  2. Is there a way to coax a desired second/third order sort by creatively naming something or perhaps the placement/order of the task definition in app_settings.json (like in Targets)?

I see there is a priority property, but from what I can tell, it doesn’t control the order of tasks, it only “decorates” the task differently with an additional line of text and perhaps a different icon.

For reference, issue #5997 is related/relevant.

1 Like

Sorting is done solely by the due date of the task. If two tasks have exactly the same due date then the ordering is not guaranteed.

However, while the task only shows a date, the internal value used for ordering can be a full date time, which means you could provide hours, minutes, seconds, or milliseconds to enforce the ordering without changing the rendering. I’d recommend using smaller units (milliseconds) otherwise it may actually change the due date depending on the timezone.

Note that I haven’t tested this but as far as I can tell it would work, but let me know how you get on!

1 Like