In some application, I’m currently using native code to wrap
String.prototype.localeCompare in order for a model name starting with an accent like “É” not to end up after a name starting with a “V” for example.
Using a port doesn’t really makes sense to me (please correct me if I’m wrong).
I assume the best way would be to reimplement locale-based sorting in some localization package, but I have no idea of the amount of work required to do so…
Does this already exist somewhere?
Or is somebody already planning to implement it in its own package?
I just switched the native code with
NaturalOrdering.compare and everything seems to work as expected.
This package doesn’t take locales into account at all. It just removes diacritics for comparing. Maybe it does the trick for the OP but in any case it would be interesting to know how to interface with this function from Elm.
@Hector Definitely! (although I’m quite happy with the current solution)
I think the way you’d interface with the function depends on your use case. If you wanted to sort a list, it might be reasonable to send the list through a port and sort it using localeCompare, then send back the sorted list and store it in your model.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.