I have a todo list in a text file that I maintain with TaskAgent and emacs. TaskAgent adds trailing text to a line to indicate priority (#!!! represents highest, #! represents low, and no mark is lowest). I would like to sort the lines by priority in emacs from highest to lowest, for example:
groceries
haircut #!!
water plants #!!!
clean gutters #!
would be sorted as
water plants #!!!
haircut #!!
clean gutters #!
groceries
(sort-regexp-fields t "^.*$" "#!+" (point-min) (point-max))
almost works but ignores the lowest priority (non-marked) items