Sort To-Do Lists

Shopping List has the ability to sort alphabetically. But, To-do lists do not.

It would be great if we can choose sort by name, sort by date or no sort (sort manually as it is now) and of course sort direction. I’m using todos for daily notes, but newest at the bottom is not optimal and every new just moving at top manually also not good.

Since the recent refactorings not anymore, right?

Update: I just realized the shopping_list.sort service action is still there and works as expected. There’s just no UI for this. Thus, I simply created an automation to always sort the shopping list after being edited:

alias: Sort shopping list alphabetically
description: ""
trigger:
  - platform: event
    event_type: shopping_list_updated
condition: []
action:
  - service: shopping_list.sort
    metadata: {}
    data:
      reverse: false
mode: single

Regardless of the above, I totally support this feature request!

Just spent a while searching and am rather surprised that you can’t sort the lists. I thought I just couldnt get it figured out.
So yeah another vote to be able to sort the lists.
Both the to do AND the completed.
For example a shopping list with many completed items that will be reused…would be nice to sort to be able to find something in the completed list to put back on the shopping list.

2 Likes

Even better if there is Priority field added to To-Do item, and we can sort by that. That way you could have calendars synced from WebDav (NextCloud for example) sorted properly, too.

This is a good idea, but your automation needs a tweak in order to avoid an endless loop. This is because calling the shopping_list.sort action will fire a shopping_list_updated event itself, which will trigger the automation again and fire another event.

You can fix this by adding a filter to your trigger so that it only triggers in response to an item being added to the shopping list and ignores a sort action.

alias: "Sort shopping list alphabetically"
description: ""
trigger:
  - platform: event
    event_type: shopping_list_updated
    event_data:
      action: add
condition: []
action:
  - data:
      reverse: false
    action: shopping_list.sort
mode: single
2 Likes

I used to run the shopping_list.sort service action every night on an automation. But recently we’ve gone to using multiple to-do lists for the multiple stores we shop at (one for Costco, one for our local grocery store, etc) so I had to switch to the Local To-Do integration. I’m missing the sort action quite a bit. Until we get one added to the To-Do integration, does anyone already have a script that would do it?

By the way, another great action for the To-Do integration would be one that would remove duplicates. (I have found a script in anther thread that can do that though.)

Use case: My wife likes to look through checked items and uncheck them when we need them again. On the other hand, I often just enter the item again. So after we’ve shopped, we often end up with multiple duplicate completed items. I’d love to be able to both sort and remove duplicates (including completed items).

1 Like