Elm Exactly
Results / elm-core /

SortByIdentityEmptyStringTest

elm-0.19.1 passelm-0.19.2 passelm-0.19.3 passlamdera-1.5.0 pass
`List.sortBy identity` on a list of Strings that contains `""` twice puts both empty strings first.

The empty string is less than any non-empty string, so `[ "", "b", "", "a" ]`
sorts to `["","","a","b"]`.

Results

elm-0.19.1

passran in 58 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: ["","","a","b"]

elm-0.19.2

passran in 63 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: ["","","a","b"]

elm-0.19.3

passran in 50 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: ["","","a","b"]

lamdera-1.5.0

passran in 62 ms
Output
result: ["","","a","b"]

Discussions

Discuss this test·Search the discussions on GitHub

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

Source

The -- CHECK: lines give the expected output.

module SortByIdentityEmptyStringTest exposing (main)
{-| `List.sortBy identity` on a list of Strings that contains `""` twice puts both empty strings first.
The empty string is less than any non-empty string, so `[ "", "b", "", "a" ]`
sorts to `["","","a","b"]`.
-}
-- CHECK: result: ["","","a","b"]
import Html exposing (text)
main =
let
result : List String
result = List.sortBy identity [ "", "b", "", "a" ]
_ = Debug.log "result" result
in
text "done"