Elm Exactly
Results / elm-core /

SortWithCompareEmptyStringTest

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

`[ "", "b", "a", "" ]` sorts to `["","","a","b"]`.

Results

elm-0.19.1

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

elm-0.19.3

passran in 39 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/SortWithCompareEmptyStringTest] in its title.

Source

The -- CHECK: lines give the expected output.

module SortWithCompareEmptyStringTest exposing (main)
{-| `List.sortWith compare` on a list of Strings that contains `""` twice puts both empty strings first.
`[ "", "b", "a", "" ]` sorts to `["","","a","b"]`.
-}
-- CHECK: result: ["","","a","b"]
import Html exposing (text)
main =
let
result : List String
result = List.sortWith compare [ "", "b", "a", "" ]
_ = Debug.log "result" result
in
text "done"