Reverse sort
This commit is contained in:
parent
966744f709
commit
fdea37d9b8
24
app/Main.hs
24
app/Main.hs
@ -1,14 +1,18 @@
|
|||||||
module Main where
|
module Main where
|
||||||
|
|
||||||
import System.Posix.Directory ( getWorkingDirectory )
|
import System.Posix.Directory ( getWorkingDirectory )
|
||||||
import System.Directory
|
import System.Directory
|
||||||
( pathIsSymbolicLink, doesFileExist, getFileSize, doesDirectoryExist )
|
( pathIsSymbolicLink
|
||||||
import Data.Functor ( (<&>) )
|
, doesFileExist
|
||||||
import Control.Monad ( filterM )
|
, getFileSize
|
||||||
import System.Directory.Extra ( listContents )
|
, doesDirectoryExist )
|
||||||
import Brick
|
import Data.Functor ( (<&>) )
|
||||||
import Graphics.Vty
|
import Control.Monad ( filterM )
|
||||||
import Data.List.Extra
|
import System.Directory.Extra ( listContents )
|
||||||
|
import Brick
|
||||||
|
import Graphics.Vty
|
||||||
|
import Data.List.Extra
|
||||||
|
import qualified Data.Ord
|
||||||
|
|
||||||
listNonSymFiles :: FilePath -> IO [FilePath]
|
listNonSymFiles :: FilePath -> IO [FilePath]
|
||||||
listNonSymFiles dir = filterM (fmap not . pathIsSymbolicLink) =<< filterM doesFileExist =<< listContents dir
|
listNonSymFiles dir = filterM (fmap not . pathIsSymbolicLink) =<< filterM doesFileExist =<< listContents dir
|
||||||
@ -21,7 +25,7 @@ getSizeSubpaths x = do
|
|||||||
sub <- listNonSymDirectories x
|
sub <- listNonSymDirectories x
|
||||||
subby <- mapM (\y -> (y,) . sum . map snd <$> getSizeSubpaths y) sub
|
subby <- mapM (\y -> (y,) . sum . map snd <$> getSizeSubpaths y) sub
|
||||||
local <- listNonSymFiles x >>= (\y -> mapM getFileSize y <&> zip y)
|
local <- listNonSymFiles x >>= (\y -> mapM getFileSize y <&> zip y)
|
||||||
pure $ local ++ subby
|
pure $ sortOn (Data.Ord.Down . snd) $ local ++ subby
|
||||||
|
|
||||||
data AppS = AppS
|
data AppS = AppS
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user