-
Notifications
You must be signed in to change notification settings - Fork 361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Case sensitivity when sorting strings is difficult to deal with #1140
Comments
Thanks for reporting this! To set expectations:
Finally, please be patient with the core team. They are trying their best with limited resources. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We have many places in our code base where we need to sort strings to be displayed in the UI, which we normally do by calling either
compare
,List.sort
orList.sortBy
. All of these functions will sort strings in a case sensitive manner though, which is rarely what we want. That is, sorting a list of strings ala[ "a", "c", "B" ]
will give[ "B", "a", "c" ]
when we really want[ "a", "B", "c" ]
.The simplest fix for this is to remember to always call
String.toLower
in the appropriate places before sorting, but this has proven untenable in the long run for our big code base with many developers on it. We're now starting to ban callingcompare
directly usingelm-review
and only allowing wrappers which force you to explicitly choose the ordering you want (e.g.compareStringsIgnoreCasing
andcompareStringsWithCasing
). This works, but also has downsides, like how we can't have those wrappers takecomparable
arguments, but onlyString
, so now must tighten our types in places that could previously usecomparable
types to beString
for example.All in all, the current API doesn't feel like it has any good solutions for this.
The text was updated successfully, but these errors were encountered: