summaryrefslogtreecommitdiff
path: root/src/Text/Hakyll
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2010-01-29 18:36:42 +0100
committerJasper Van der Jeugt <jaspervdj@gmail.com>2010-01-29 18:36:42 +0100
commitc49cc9a046aef1f42564857b08c19ed43dd3f263 (patch)
tree66b49a4f2147a4142f4eb6c638134ef9491809c3 /src/Text/Hakyll
parent4f335aa6a2ffcd663c4bdb2c139bf4e1ea5237bf (diff)
downloadhakyll-c49cc9a046aef1f42564857b08c19ed43dd3f263.tar.gz
Added a sortByBaseName function.
Diffstat (limited to 'src/Text/Hakyll')
-rw-r--r--src/Text/Hakyll/File.hs9
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:
--