From: Ufuk Kayserilioglu via ruby-core Date: 2024-05-27T14:02:32+03:00 Subject: [ruby-core:118030] Re: Provide utf-8 sorting for ruby next --===============3083650958978969498== Content-Type: multipart/alternative; boundary="000000000000e275e006196d74b6" --000000000000e275e006196d74b6 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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", "=C4=B1"].sort_alphabetical =3D> ["i", "=C4=B1"] irb(main):002:0> ["i", "=C4=B1", "=C3=BC", "u"].sort_alphabetical =3D> ["i", "u", "=C3=BC", "=C4=B1"] ``` None of the above results make any sense for Turkish character sorting, the expected sorting should have been `["=C4=B1", "i", "u", "=C3=BC"]` which yo= u 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/ > --000000000000e275e006196d74b6 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
This proposal does not make sense, since sorting non-ASCII= strings is locale dependent, so there can't exist a `sort_by_utf` meth= od. The `sort_alphabetical` gem is broken in this regard, as well:
```i= rb
$ irb -rsort_alphabetical
irb(main):001:0> ["i"= ;, "=C4=B1"].sort_alphabetical
=3D> ["i", "= =C4=B1"]
irb(main):002:0> ["i", "=C4=B1", &q= uot;=C3=BC", "u"].sort_alphabetical
=3D> ["i"= ;, "u", "=C3=BC", "=C4=B1"]
=
```
None of the above results make any sense for Tur= kish character sorting, the expected sorting should have been `["=C4= =B1", "i", "u", "=C3=BC"]` which you can= see here:=C2=A0https://simple.wikipedia.org/wiki/Turkish_alphabet

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

Ufuk Kayseriliogl= u


On Mon, 27 May 2024 at 13:34, d_rems--- via ruby-cor= e <ruby-core@ml.ruby-lang.= org> wrote:
Since it has been declared that frozen_string_literal will print warning= s in Ruby 3.4. and will be mandatory in the future I must warn, that ruby s= till 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://gith= ub.com/grosser/sort_alphabetical ] for a long time and it works good fo= r me. Problem is that it depends on unicode_utils gem [ https:/= /github.com/lang/unicode_utils ] which looks like a=C2=A0 dead reposito= ry, since repository owner has not been active for a decade.

And unicode_utils use a lot of code which is not complied with frozen_strin= g_literal.

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

Thanks

by
TheR
=C2=A0______________________________________________
=C2=A0ruby-core mailing list -- ruby-core@ml.ruby-lang.org
=C2=A0To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
=C2=A0ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.o= rg/
--000000000000e275e006196d74b6-- --===============3083650958978969498== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ______________________________________________ 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/ --===============3083650958978969498==--