SortEmptyStringInListTest
`List.sort` on a list of Strings that contains `""` twice puts both empty strings first. `[ "", "b", "", "a" ]` sorts to `["","","a","b"]`. The same input is sorted with `List.sortBy identity` in `SortByIdentityEmptyStringTest`.
Results
elm-0.19.1
passran in 41 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 48 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 57 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 78 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/SortEmptyStringInListTest] in its title.
Source
The -- CHECK: lines give the expected output.
module SortEmptyStringInListTest exposing (main)
{-| `List.sort` on a list of Strings that contains `""` twice puts both empty strings first.
`[ "", "b", "", "a" ]` sorts to `["","","a","b"]`. The same input is sorted with
`List.sortBy identity` in `SortByIdentityEmptyStringTest`.
-}
-- CHECK: result: ["","","a","b"]
import Html exposing (text)
main =
let
result : List String
result = List.sort [ "", "b", "", "a" ]
_ = Debug.log "result" result
in
text "done"