todotxt / todo.txt-cli

☑️ A simple and extensible shell script for managing your todo.txt file.
http://todotxt.org
GNU General Public License v3.0
5.52k stars 710 forks source link

Tasks with no priority sort before prioritized tasks if they start with ASCII char before '(' #279

Open NightFlyer opened 5 years ago

NightFlyer commented 5 years ago

Do you want to request a feature or report a bug? bug

What is the current behavior? If you have a task that starts with an ASCII character before '(' (such as # or double quote), that task will sort before any of the priority tasks. So, what you get are:

  1. unprioritized tasks that start with an ASCII character before '('
  2. prioritized tasks
  3. unprioritized tasks that start ASCII character after '('

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Use a todo.txt such as the following:

(A) high priority task
(B) medium priority task
"funny" task
Another task
(A) "funny" priority task

then do todo.sh ls will show:

3 "funny" task
5 (A) "funny" priority task
1 (A) high priority task
2 (B) medium priority task
4 Another task

What is the expected behavior? The expected behavior is that all unprioritized tasks will sort after prioritized tasks.

5 (A) "funny" priority task
1 (A) high priority task
2 (B) medium priority task
3 "funny" task
4 Another task

Which versions todo.sh are you using?

Run todo.sh -V TODO.TXT Command Line Interface v2.11.0

Which Operating System are you using? MacOS 10.13.6

Which version of bash are you using?

Run bash --version GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin17)

the1ts commented 3 years ago

This appears to be because of the LC_COLLATE=C in the default TODOTXT_SORT_COMMAND. You can try setting this in your todo.cfg to remove it. Seems to ignore non-alphanumeric characters and allow the priority sorting. TODOTXT_SORT_COMMAND="sort -f -k2"