summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2017-02-01 11:31:58 +1100
committerJed Barber <jjbarber@y7mail.com>2017-02-01 11:31:58 +1100
commit685602ca6a4af17e6e6620527d8c0e6897393b2c (patch)
tree2c3db6dd3790db02998ec7805e9ddf1936781cad /src
parenta466147461556b68e702368caee96c785d39b9d4 (diff)
Fixed candidate ordering bug for groups AA and beyond
Diffstat (limited to 'src')
-rw-r--r--src/Candidate.hs14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/Candidate.hs b/src/Candidate.hs
index 21f9736..e92fd05 100644
--- a/src/Candidate.hs
+++ b/src/Candidate.hs
@@ -59,7 +59,7 @@ readCandidates inputFile state = do
if (Either.isRight t1) && (Maybe.isJust t2)
then readFunc (t3:r) tx
else readFunc r tx
- raw <- readFunc [] e >>= return . (List.sort)
+ raw <- readFunc [] e >>= return . (List.sortBy candRecComp)
IO.hClose h
return (makeAboveBallot raw, makeBelowBallot raw)
@@ -67,6 +67,18 @@ readCandidates inputFile state = do
+-- assumes there are at least two items in each list
+-- see the above function for the things it gets applied on for why
+candRecComp :: [String] -> [String] -> Ordering
+candRecComp a b =
+ let lenResult = compare (length (head a)) (length (head b))
+ in if (lenResult == EQ)
+ then compare (take 2 a) (take 2 b)
+ else lenResult
+
+
+
+
-- very hacky, pls revise
makeAboveBallot :: [[String]] -> AboveLineBallot
makeAboveBallot input =