From 0b7a50d0f09f8d1b654efff720b1378907b4ba5f Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 21 Sep 2017 10:31:15 -1000 Subject: [PATCH] import: sort new transactions by date, across files --- hledger/Hledger/Cli/Commands/Import.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hledger/Hledger/Cli/Commands/Import.hs b/hledger/Hledger/Cli/Commands/Import.hs index a75d6c2bb..02e6b95a7 100755 --- a/hledger/Hledger/Cli/Commands/Import.hs +++ b/hledger/Hledger/Cli/Commands/Import.hs @@ -8,6 +8,8 @@ module Hledger.Cli.Commands.Import ( where import Control.Monad +import Data.List +import Data.Ord import Data.String.Here import Hledger import Hledger.Cli.CliOptions @@ -46,7 +48,7 @@ importcmd opts@CliOpts{rawopts_=rawopts,inputopts_=iopts} j = do case enewj of Left e -> error' e Right newj -> - case jtxns newj of + case sortBy (comparing tdate) $ jtxns newj of [] -> putStrLn "no new transactions" newts | dryrun -> do printf "would import %d new transactions:\n\n" (length newts)