SortWithCompareEmptyStringTest
`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 msOutput
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 msOutput
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 msOutput
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 msOutput
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"