summaryrefslogtreecommitdiff
path: root/Handler/Common.hs
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2017-03-16 14:41:08 +0100
committerGregor Kleen <gkleen@yggdrasil.li>2017-03-16 14:41:08 +0100
commit37a032885b24bfaef9c493ff95294b65146b0f89 (patch)
tree42fc074e4bba496c48c0fac472a4d8b829725d92 /Handler/Common.hs
parentab9dd6209e26ad9856e8cf41c1597a01073d4053 (diff)
downloadbar-37a032885b24bfaef9c493ff95294b65146b0f89.tar
bar-37a032885b24bfaef9c493ff95294b65146b0f89.tar.gz
bar-37a032885b24bfaef9c493ff95294b65146b0f89.tar.bz2
bar-37a032885b24bfaef9c493ff95294b65146b0f89.tar.xz
bar-37a032885b24bfaef9c493ff95294b65146b0f89.zip
Even fancier sorting
Diffstat (limited to 'Handler/Common.hs')
-rw-r--r--Handler/Common.hs3
1 files changed, 2 insertions, 1 deletions
diff --git a/Handler/Common.hs b/Handler/Common.hs
index f40375a..90e373a 100644
--- a/Handler/Common.hs
+++ b/Handler/Common.hs
@@ -265,10 +265,11 @@ kinds = do
265type Sort a = a -> a 265type Sort a = a -> a
266 266
267stockSort :: Sort [WithType (Entity Item)] 267stockSort :: Sort [WithType (Entity Item)]
268stockSort = concat . map (sortOn $ entityVal . typedVal) . sortGroups . group 268stockSort = concat . map sortInGroup . sortGroups . group
269 where 269 where
270 group = groupBy ((==) `on` valType) . sortOn valType 270 group = groupBy ((==) `on` valType) . sortOn valType
271 sortGroups = sortOn (fmap minimum . fromNullable . map (entityVal . typedVal)) 271 sortGroups = sortOn (fmap minimum . fromNullable . map (entityVal . typedVal))
272 sortInGroup = concat . map (sortOn $ entityVal . typedVal) . sortOn (fmap minimum . fromNullable . map (entityVal . typedVal)) . groupBy ((==) `on` (itemNormKind . entityVal . typedVal)) . sortOn (itemNormKind . entityVal . typedVal)
272 273
273referenceSort :: Sort [WithType (Entity Reference)] 274referenceSort :: Sort [WithType (Entity Reference)]
274referenceSort = sortBy referenceOrdering 275referenceSort = sortBy referenceOrdering