Elm Exactly
Results / elm-core /

SortByDerivedEmptyListTest

elm-0.19.1 passelm-0.19.2 passelm-0.19.3 passlamdera-1.5.0 pass
`List.sortBy List.reverse` sorts a list of lists, two of them empty, by their reversed contents.

The keys are `[2,1]`, `[]`, `[3]` and `[]`. Lists compare element by element and
`[]` sorts first, so the result is the two empty lists in input order, then
`[1,2]` (key `[2,1]`), then `[3]`.

Results

elm-0.19.1

passran in 57 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],[3]]

elm-0.19.2

passran in 51 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],[3]]

elm-0.19.3

passran in 78 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],[3]]

lamdera-1.5.0

passran in 46 ms
Output
result: [[],[],[1,2],[3]]

Discussions

Discuss this test·Search the discussions on GitHub

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

Source

The -- CHECK: lines give the expected output.

module SortByDerivedEmptyListTest exposing (main)
{-| `List.sortBy List.reverse` sorts a list of lists, two of them empty, by their reversed contents.
The keys are `[2,1]`, `[]`, `[3]` and `[]`. Lists compare element by element and
`[]` sorts first, so the result is the two empty lists in input order, then
`[1,2]` (key `[2,1]`), then `[3]`.
-}
-- CHECK: result: [[],[],[1,2],[3]]
import Html exposing (text)
main =
let
emptyL : List Int
emptyL = []
result : List (List Int)
result = List.sortBy List.reverse [ [ 1, 2 ], emptyL, [ 3 ], emptyL ]
_ = Debug.log "result" result
in
text "done"