Elm Exactly
Results / elm-core /

SortWithCompareEmptyListTest

elm-0.19.1 passelm-0.19.2 passelm-0.19.3 passlamdera-1.5.0 pass
`List.sortWith compare` on a `List (List Int)` that contains `[]` twice puts the empty lists first.

`[ [ 1 ], [], [ 2 ], [] ]` sorts to `[[],[],[1],[2]]`, the same result `List.sort`
gives in `SortEmptyListInListTest`.

Results

elm-0.19.1

passran in 54 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets.
result: [[],[],[1],[2]]

elm-0.19.2

passran in 65 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets.
result: [[],[],[1],[2]]

elm-0.19.3

passran in 68 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets.
result: [[],[],[1],[2]]

lamdera-1.5.0

passran in 71 ms
Output
result: [[],[],[1],[2]]

Discussions

Discuss this test·Search the discussions on GitHub

Discussions are on GitHub; one about this test has [t:elm-core/SortWithCompareEmptyListTest] in its title.

Source

The -- CHECK: lines give the expected output.

module SortWithCompareEmptyListTest exposing (main)
{-| `List.sortWith compare` on a `List (List Int)` that contains `[]` twice puts the empty lists first.
`[ [ 1 ], [], [ 2 ], [] ]` sorts to `[[],[],[1],[2]]`, the same result `List.sort`
gives in `SortEmptyListInListTest`.
-}
-- CHECK: result: [[],[],[1],[2]]
import Html exposing (text)
main =
let
emptyL : List Int
emptyL = []
result : List (List Int)
result = List.sortWith compare [ [ 1 ], emptyL, [ 2 ], emptyL ]
_ = Debug.log "result" result
in
text "done"