on master help sign in
Added a sortByBaseName function.
commitc49cc9a046aef1f42564857b08c19ed43dd3f263 authorJasper Van der Jeugt <jaspervdj@gmail.com> dateFri 29 Jan 2010, 18:36 (17 years ago) parent4f335aa
1 file changed+8−1
src/Text/Hakyll/File.hs+8−1
src/Text/Hakyll/File.hs+8−1
@@ -8,6 +8,7 @@ module Text.Hakyll.File
88 , removeSpaces
99 , makeDirectories
1010 , getRecursiveContents
11+ , sortByBaseName
1112 , havingExtension
1213 , isMoreRecent
1314 , directory
@@ -16,7 +17,7 @@ module Text.Hakyll.File
1617import System.Directory
1718import System.FilePath
1819import Control.Monad
19−import Data.List (isPrefixOf)
20+import Data.List (isPrefixOf, sortBy)
2021import Control.Monad.Reader (liftIO)
2122
2223import Text.Hakyll.Hakyll
@@ -100,6 +101,12 @@ getRecursiveContents topdir = do
100101 where
101102 isProper = not . (== '.') . head
102103
104+-- | Sort a list of filenames on the basename.
105+sortByBaseName :: [FilePath] -> [FilePath]
106+sortByBaseName = sortBy compareBaseName
107+ where
108+ compareBaseName f1 f2 = compare (takeFileName f1) (takeFileName f2)
109+
103110-- | A filter that takes all file names with a given extension. Prefix the
104111-- extension with a dot:
105112--