From 7fb6e1f8331331d65d0f7c8466ecafa0a19d4e24 Mon Sep 17 00:00:00 2001 From: pingu Date: Sat, 14 Oct 2023 13:49:13 +0200 Subject: [PATCH] Reverse sort --- app/Main.hs | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/app/Main.hs b/app/Main.hs index 8978d99..0852083 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -1,14 +1,18 @@ module Main where -import System.Posix.Directory ( getWorkingDirectory ) -import System.Directory - ( pathIsSymbolicLink, doesFileExist, getFileSize, doesDirectoryExist ) -import Data.Functor ( (<&>) ) -import Control.Monad ( filterM ) -import System.Directory.Extra ( listContents ) -import Brick -import Graphics.Vty -import Data.List.Extra +import System.Posix.Directory ( getWorkingDirectory ) +import System.Directory + ( pathIsSymbolicLink + , doesFileExist + , getFileSize + , doesDirectoryExist ) +import Data.Functor ( (<&>) ) +import Control.Monad ( filterM ) +import System.Directory.Extra ( listContents ) +import Brick +import Graphics.Vty +import Data.List.Extra +import qualified Data.Ord listNonSymFiles :: FilePath -> IO [FilePath] listNonSymFiles dir = filterM (fmap not . pathIsSymbolicLink) =<< filterM doesFileExist =<< listContents dir @@ -21,7 +25,7 @@ getSizeSubpaths x = do sub <- listNonSymDirectories x subby <- mapM (\y -> (y,) . sum . map snd <$> getSizeSubpaths y) sub local <- listNonSymFiles x >>= (\y -> mapM getFileSize y <&> zip y) - pure $ local ++ subby + pure $ sortOn (Data.Ord.Down . snd) $ local ++ subby data AppS = AppS {