From 37a032885b24bfaef9c493ff95294b65146b0f89 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Thu, 16 Mar 2017 14:41:08 +0100 Subject: Even fancier sorting --- Handler/Common.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Handler') 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 type Sort a = a -> a stockSort :: Sort [WithType (Entity Item)] -stockSort = concat . map (sortOn $ entityVal . typedVal) . sortGroups . group +stockSort = concat . map sortInGroup . sortGroups . group where group = groupBy ((==) `on` valType) . sortOn valType sortGroups = sortOn (fmap minimum . fromNullable . map (entityVal . typedVal)) + sortInGroup = concat . map (sortOn $ entityVal . typedVal) . sortOn (fmap minimum . fromNullable . map (entityVal . typedVal)) . groupBy ((==) `on` (itemNormKind . entityVal . typedVal)) . sortOn (itemNormKind . entityVal . typedVal) referenceSort :: Sort [WithType (Entity Reference)] referenceSort = sortBy referenceOrdering -- cgit v1.2.3