SortByDerivedEmptyStringTest
`List.sortBy String.reverse` sorts strings by their reversed text, with the empty strings first. The input is `[ "", "ba", "a", "" ]`, giving keys `""`, `"ab"`, `"a"` and `""`. The empty key sorts first and `"a"` before `"ab"`, so the result is `["","","a","ba"]`.
Results
elm-0.19.1
passran in 78 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","ba"]
elm-0.19.2
passran in 61 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","ba"]
elm-0.19.3
passran in 46 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","ba"]
lamdera-1.5.0
passran in 75 msOutput
result: ["","","a","ba"]
Discussions
Discuss this test·Search the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm-core/SortByDerivedEmptyStringTest] in its title.
Source
The -- CHECK: lines give the expected output.
module SortByDerivedEmptyStringTest exposing (main)
{-| `List.sortBy String.reverse` sorts strings by their reversed text, with the empty strings first.
The input is `[ "", "ba", "a", "" ]`, giving keys `""`, `"ab"`, `"a"` and `""`.
The empty key sorts first and `"a"` before `"ab"`, so the result is
`["","","a","ba"]`.
-}
-- CHECK: result: ["","","a","ba"]
import Html exposing (text)
main =
let
result : List String
result = List.sortBy String.reverse [ "", "ba", "a", "" ]
_ = Debug.log "result" result
in
text "done"