Skip to content
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

Open
KasMA1990 opened this issue Sep 21, 2023 · 1 comment
Open

Case sensitivity when sorting strings is difficult to deal with #1140

KasMA1990 opened this issue Sep 21, 2023 · 1 comment

Comments

@KasMA1990
Copy link

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 or List.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 calling compare directly using elm-review and only allowing wrappers which force you to explicitly choose the ordering you want (e.g. compareStringsIgnoreCasing and compareStringsWithCasing). This works, but also has downsides, like how we can't have those wrappers take comparable arguments, but only String, so now must tighten our types in places that could previously use comparable types to be String for example.

All in all, the current API doesn't feel like it has any good solutions for this.

@github-actions
Copy link

Thanks for reporting this! To set expectations:

  • Issues are reviewed in batches, so it can take some time to get a response.
  • Ask questions a community forum. You will get an answer quicker that way!
  • If you experience something similar, open a new issue. We like duplicates.

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant