From: "naruse (Yui NARUSE) via ruby-core" Date: 2024-01-05T14:11:03+00:00 Subject: [ruby-core:116031] [Ruby master Bug#20148] Sorting not working as expected on Urdu words. Issue #20148 has been updated by naruse (Yui NARUSE). As Martin says Ruby's `Array#sort` just uses simple Unicode scalar value sort, which is not what you expect. For the use case which considers the knowledge of the language, you need to use "Collation". RDB sometimes implements collation. In Ruby for example you can use twitter-cldr-rb. https://github.com/twitter/twitter-cldr-rb?tab=readme-ov-file#sorting-collation ``` irb(main):001> require 'twitter_cldr' => true irb(main):002> ['��', '��', '��', '��', '��'].sort => ["��", "��", "��", "��", "��"] irb(main):003> ['��', '��', '��', '��', '��'].localize(:ur).sort.to_a => ["��", "��", "��", "��", "��"] ``` ---------------------------------------- Bug #20148: Sorting not working as expected on Urdu words. https://bugs.ruby-lang.org/issues/20148#change-106026 * Author: zohaibnadeem13@gmail.com (Zohaib Nadeem) * Status: Rejected * Priority: Normal * ruby -v: 3.1.4 * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- I was trying to sort an array of Urdu characters and found out an ambiguity in the result. Here is the script that I am using. ['��', '��', '��', '��', '��'].sort Actual Result: ["��", "��", "��", "��", "��"] Expected Result: ["��", "��", '��', "��", "��"] -- https://bugs.ruby-lang.org/ ______________________________________________ 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/