Sorting tasks by names sometimes considers tags
I am having some difficulty with the "sort by name" functionality inside a project. It seems that sort by name seems to be sensitive to whether or not a task has a tag. Let's give an example to make this easier. If I have the following 4 tasks:
@waiting @project ABC
I would expect "sort by name" to generate:
but instead I get:
It seems that the lack of a tag on DEF makes a difference to the sort algorithm when I am not sure that it should. Clearly the tag names aren't sorted alphabetically but just there presence is considered in the sort.
Is this the way sorting is designed to work?
Asked by David Morlitz on Sep 25, 2013 - 12:39
The label for a task should not make a difference when sorting by name. Are there any other details of these tasks, such as are they all with dates and times, or without? Does this only happen with one Project, or all Projects you have?
I would suggest clearing the cache for your browser, and then logging back in.
Thank you for the suggestions - but they did not make any difference. I even logged in from a computer that I have never used with Todoist before.
The scenario can be easily reproduced. Here are the steps I used to test it:
1) Create a new project
2) Click "Create a task"
3) Enter (without the quotes) "@contact ABC" and hit Enter
4) Enter (without the quotes) "DEF" and hit Enter
5) Enter (without the quotes) "@contact GHI" and hit Enter
When you then sort by name, you will get:
I think that the sort is considering the space character between the tags as part of the task name, which is causing the situation.
Now, I have also noticed that the situation is different if you enter "ABC" then click on the @ sign and select a tag name. This seems to sort properly. However, if you then edit the text (which Todoist replaces with "@contact ABC" syntax) and save the updates, then the sorting is off again.
None of these tasks have any other details in them than the 1 tag and title that I described above.
David - thank you for the update. I understand that the tag is stored at the front of the task name, but it seems to be a bit more complex than that. I tried entering the following 3 tasks (all without the quotes in this order:
1) "@xyc GHI"
2) "@qrs JKL"
If the sorting considers the tag name, then I would have expected to get:
2, 1, 3 (because q comes before x)
but instead, I got
1, 2, 3
This made me think that the tag names are stripped out. Then I added a 4th task:
4) " ABC" (***Note: there is a space before the letter A)
Now, when I sort by name, I get 4, 1, 2, 3. (and I verified that the space is still in #4)
This leads me to believe that the tags are somehow stripped out before sorting, but that the space between the last tag and the real text of the task name is not. This would cause the appearance of all tasks with tags sorting first because space comes before letters. When stripping the tags, I think it would be worthwhile to also remove the space after the tags so that sorting works as it should.
I am not sure if this is as difficult a fix as you first thought, if the tag stripping logic is already there.
Of course, another option is to store the tag names at the end of the task and then this issue goes away. I do realize that doing this would be a significant change and probably not worth the effort.
I entered all of the tasks without the quotes. Would it help if you took a look at my account? I have a project called test with 4 items in it.
I see that when I save a task the space seems to disappear. The sort still seems to take that space into account, though. If I edit a task and put the space back in front and save the task moves to the top. If I clear out the entire task name and put it in without the space, it sorts under ones that started with a space or tags.
I can also do a screen share with you, if that helps you see what is going on. I have a feeling that just looking at my tasks might clear it up.
Right now, the test project contains (after sorting by name)
There's no way I could look at your data, the hassle required for this (your permission, separation of your data, moving it to an anonymous installment where the text changes to xxxx etc.) would be too much, but if this is a global issue, I must be able to reproduce this on any account when following the steps you describe exactly.
Anyway, thank you for clarifying that you are adding the space *after* the task is saved while editing it. This way I could now reproduce this and when editing ABC and adding a space at the front, it will indeed jump to the top as the space seems to be higher sorted than the @ of a label.
I have passed this to the developers too and we'll look into it as I'm not 100% sure myself which part of this is a bug and if this could help solve the label issue too.