diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2017-03-16 14:41:08 +0100 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2017-03-16 14:41:08 +0100 |
commit | 37a032885b24bfaef9c493ff95294b65146b0f89 (patch) | |
tree | 42fc074e4bba496c48c0fac472a4d8b829725d92 /Handler/Common.hs | |
parent | ab9dd6209e26ad9856e8cf41c1597a01073d4053 (diff) | |
download | bar-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.hs | 3 |
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 | |||
265 | type Sort a = a -> a | 265 | type Sort a = a -> a |
266 | 266 | ||
267 | stockSort :: Sort [WithType (Entity Item)] | 267 | stockSort :: Sort [WithType (Entity Item)] |
268 | stockSort = concat . map (sortOn $ entityVal . typedVal) . sortGroups . group | 268 | stockSort = 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 | ||
273 | referenceSort :: Sort [WithType (Entity Reference)] | 274 | referenceSort :: Sort [WithType (Entity Reference)] |
274 | referenceSort = sortBy referenceOrdering | 275 | referenceSort = sortBy referenceOrdering |