SortByIdentityEmptyStringTest
`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 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 63 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 50 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/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"