Sort elements before converting to string

Just in case...
This commit is contained in:
Joscha 2018-01-05 17:14:09 +00:00
parent 8d882cf861
commit e9b4edc6e0

View file

@ -26,6 +26,7 @@ module Cards
import Control.Applicative import Control.Applicative
import Control.Monad import Control.Monad
import Data.Function
import Data.List import Data.List
import qualified Data.Map.Strict as Map import qualified Data.Map.Strict as Map
import Data.Time import Data.Time
@ -223,7 +224,7 @@ nomToInteger = (truncate :: Double -> Integer) . realToFrac
-- This string can then be written to a text file for storage. -- This string can then be written to a text file for storage.
elementsToString :: Elements -> String elementsToString :: Elements -> String
elementsToString (Elements e) = elementsToString (Elements e) =
let elms = map snd $ Map.toList e let elms = map snd $ sortBy (compare `on` fst) $ Map.toList e
in unlines $ intersperse "" $ map (\x -> elementToString x) elms in unlines $ intersperse "" $ map (\x -> elementToString x) elms
elementToString :: Element -> String elementToString :: Element -> String