blob: 16e8f5e587e27c74b1e1445cb84849cbd83f31ff (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
module Model.Round
( Round
, maybeBestRound
) where
import List
import Time (Time)
type alias Round =
{ duration : Time
, score : Int
}
maybeBestRound : List Round -> Maybe Round
maybeBestRound rounds =
let orderedRounds =
rounds
|> List.sortWith roundOrder
|> List.reverse
in case orderedRounds of
[] -> Nothing
best :: _ -> Just best
roundOrder : Round -> Round -> Order
roundOrder round1 round2 =
if round1.score == round2.score
then
compare round2.duration round1.duration
else
compare round1.score round2.score
|