Sort elements before converting to string
Just in case...
This commit is contained in:
parent
8d882cf861
commit
e9b4edc6e0
1 changed files with 2 additions and 1 deletions
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue