Elm Exactly
Results / elm-core /

SortByIdentityEmptyListTest

elm-0.19.1 passelm-0.19.2 passelm-0.19.3 passlamdera-1.5.0 pass
`List.sortBy identity` on a list of `List Int` values, two of which are `[]`, puts the empty lists first.

Lists compare element by element, and `[]` is less than any non-empty list, so
`[ [ 1 ], [], [ 2 ], [] ]` sorts to `[[],[],[1],[2]]`.

Results

elm-0.19.1

passran in 47 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 43 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 63 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 48 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/SortByIdentityEmptyListTest] in its title.

Source

The -- CHECK: lines give the expected output.

module SortByIdentityEmptyListTest exposing (main)
{-| `List.sortBy identity` on a list of `List Int` values, two of which are `[]`, puts the empty lists first.
Lists compare element by element, and `[]` is less than any non-empty list, so
`[ [ 1 ], [], [ 2 ], [] ]` sorts to `[[],[],[1],[2]]`.
-}
-- CHECK: result: [[],[],[1],[2]]
import Html exposing (text)
main =
let
emptyL : List Int
emptyL = []
result : List (List Int)
result = List.sortBy identity [ [ 1 ], emptyL, [ 2 ], emptyL ]
_ = Debug.log "result" result
in
text "done"