Elm Exactly
Results / elm-core /

SortByAlwaysEmptyStringKeyTest

elm-0.19.1 passelm-0.19.2 passelm-0.19.3 passlamdera-1.5.0 pass
`List.sortBy` with a key function that returns `""` for every element leaves the list in its original order.

`emptyKey` is a named top-level function that ignores its argument and returns
`""`. All keys are equal, and `List.sortBy` is stable,
so `[ 3, 1, 2 ]` stays `[3,1,2]`.

Results

elm-0.19.1

passran in 44 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: [3,1,2]

elm-0.19.2

passran in 67 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: [3,1,2]

elm-0.19.3

passran in 44 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: [3,1,2]

lamdera-1.5.0

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

Discussions

Discuss this test·Search the discussions on GitHub

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

Source

The -- CHECK: lines give the expected output.

module SortByAlwaysEmptyStringKeyTest exposing (main)
{-| `List.sortBy` with a key function that returns `""` for every element leaves the list in its original order.
`emptyKey` is a named top-level function that ignores its argument and returns
`""`. All keys are equal, and `List.sortBy` is stable,
so `[ 3, 1, 2 ]` stays `[3,1,2]`.
-}
-- CHECK: result: [3,1,2]
import Html exposing (text)
emptyKey : Int -> String
emptyKey _ =
""
main =
let
result : List Int
result = List.sortBy emptyKey [ 3, 1, 2 ]
_ = Debug.log "result" result
in
text "done"