From c49cc9a046aef1f42564857b08c19ed43dd3f263 Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Fri, 29 Jan 2010 18:36:42 +0100 Subject: Added a sortByBaseName function. --- src/Text/Hakyll/File.hs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/Text/Hakyll') 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: -- -- cgit v1.2.3