diff options
author | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2010-01-29 18:36:42 +0100 |
---|---|---|
committer | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2010-01-29 18:36:42 +0100 |
commit | c49cc9a046aef1f42564857b08c19ed43dd3f263 (patch) | |
tree | 66b49a4f2147a4142f4eb6c638134ef9491809c3 /src/Text/Hakyll | |
parent | 4f335aa6a2ffcd663c4bdb2c139bf4e1ea5237bf (diff) | |
download | hakyll-c49cc9a046aef1f42564857b08c19ed43dd3f263.tar.gz |
Added a sortByBaseName function.
Diffstat (limited to 'src/Text/Hakyll')
-rw-r--r-- | src/Text/Hakyll/File.hs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/Text/Hakyll/File.hs b/src/Text/Hakyll/File.hs index 992490c..4e7c10f 100644 --- a/src/Text/Hakyll/File.hs +++ b/src/Text/Hakyll/File.hs @@ -8,6 +8,7 @@ module Text.Hakyll.File , removeSpaces , makeDirectories , getRecursiveContents + , sortByBaseName , havingExtension , isMoreRecent , directory @@ -16,7 +17,7 @@ module Text.Hakyll.File import System.Directory import System.FilePath import Control.Monad -import Data.List (isPrefixOf) +import Data.List (isPrefixOf, sortBy) import Control.Monad.Reader (liftIO) import Text.Hakyll.Hakyll @@ -100,6 +101,12 @@ getRecursiveContents topdir = do where isProper = not . (== '.') . head +-- | Sort a list of filenames on the basename. +sortByBaseName :: [FilePath] -> [FilePath] +sortByBaseName = sortBy compareBaseName + where + compareBaseName f1 f2 = compare (takeFileName f1) (takeFileName f2) + -- | A filter that takes all file names with a given extension. Prefix the -- extension with a dot: -- |