This proposal does not make sense, since sorting non-ASCII strings is locale dependent, so there can't exist a `sort_by_utf` method. The `sort_alphabetical` gem is broken in this regard, as well:
```irb
$ irb -rsort_alphabetical
irb(main):001:0> ["i", "ı"].sort_alphabetical
=> ["i", "ı"]
irb(main):002:0> ["i", "ı", "ü", "u"].sort_alphabetical
=> ["i", "u", "ü", "ı"]
```
None of the above results make any sense for Turkish character sorting, the expected sorting should have been `["ı", "i", "u", "ü"]` which you can see here: https://simple.wikipedia.org/wiki/Turkish_alphabet

As a general point, string literals are not going to be frozen any time soon, and there will always be an option to disable it even when string literals are frozen by default. So, IMO, this is not a valid argument for adding features to Ruby.

Ufuk Kayserilioglu


On Mon, 27 May 2024 at 13:34, d_rems--- via ruby-core <ruby-core@ml.ruby-lang.org> wrote:
Since it has been declared that frozen_string_literal will print warnings in Ruby 3.4. and will be mandatory in the future I must warn, that ruby still doesn't have built in method for sorting by UTF-8 characters.

Most of string methods work OK with UTF-8 strings, but not sort.

I've been using sort_alphabetical gem [ https://github.com/grosser/sort_alphabetical ] for a long time and it works good for me. Problem is that it depends on unicode_utils gem [ https://github.com/lang/unicode_utils ] which looks like a  dead repository, since repository owner has not been active for a decade.

And unicode_utils use a lot of code which is not complied with frozen_string_literal.

I am proposing to include UTF-8 sort (ex. sort_by_utf) method into next ruby version or at least include (and correct) those two gems in a future Ruby distribution.

Thanks

by
TheR
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/