hledger icon indicating copy to clipboard operation
hledger copied to clipboard

Support --sort for register command

Open igxlin opened this issue 1 year ago • 1 comments

Look like currently hledger only print register in the order of date. The --sort option of ledger register is very helpful when users want to get the expenses of most amount. Hope to have that option in hledger.

--sort value-expression (-S)
                                 Sort  postings  by evaluating the given value-expression.  Note that a
                                 comma-separated list of expressions is allowed,  in  which  case  each
                                 sorting  term  is  used in order to determine the final ordering.  For
                                 example, to search by date and then amount, one would use:
                                       ledger reg --sort 'date, amount'
                                 The sort order may be controlled with the '-' sign.  For  example,  to
                                 sort in reverse chronological order:
                                       ledger reg --sort '-date'

igxlin avatar Mar 01 '24 14:03 igxlin

I've started working on this, and I'm curious how many value-expressions we'd want to support. I think it might be easiest to start a draft PR with support for, say, date, account, and amount, and then add more from there as needed.

Are there any other commonly used ones that anyone thinks should be included to start?

reesmichael1 avatar Jul 15 '24 16:07 reesmichael1