{"id":5979,"date":"2014-04-11T06:57:47","date_gmt":"2014-04-11T06:57:47","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/04\/11\/in-perl-see-that-is-a-variant-of-ee-collection-of-common-programming-errors\/"},"modified":"2014-04-11T06:57:47","modified_gmt":"2014-04-11T06:57:47","slug":"in-perl-see-that-is-a-variant-of-ee-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/04\/11\/in-perl-see-that-is-a-variant-of-ee-collection-of-common-programming-errors\/","title":{"rendered":"In Perl, see that &#233; is a variant of e,E-Collection of common programming errors"},"content":{"rendered":"<p>I&#8217;m making the assumption that you are sorting by English collation rules and have alphabetic text. The code below is a good start, but the real world is more complicated than that. (For example, Chinese text has different lexicographic rules depending on the context, e.g. general-purpose dictionary, karaoke song lists, electronic door bell name list, .) I cannot present a perfect solution because the question had so little information.<\/p>\n<pre><code>use 5.010;\nuse utf8;\nuse Unicode::Collate::Locale 0.96;\nuse Unicode::Normalize qw(normalize);\n\nmy $c = Unicode::Collate::Locale-&gt;new(locale =&gt; 'en');\nsay for $c-&gt;sort(qw(\n    eye\n    egg\n    estate\n    etc.\n    eleven\n    e.g.\n    England\n    ensure\n    educate\n    each\n    equipment\n    elephant\n    ex-\n    ending\n    \u00e9crit\n));\nsay '-' x 40;\nfor my $word (qw(\u00e9crit \u00cbm\u00ebhnt\u00ebhtt-R\u00ea \u00canio \u00e8cole Ead?eard Emma Edward ?fini)) {\n    say sprintf '%s should be stored under the heading %s',\n        $word, ucfirst substr normalize('D', $word), 0, 1;\n}\n\n__END__\neach\n\u00e9crit\neducate\ne.g.\negg\nelephant\neleven\nending\nEngland\nensure\nequipment\nestate\netc.\nex-\neye\n----------------------------------------\n\u00e9crit should be stored under the heading E\n\u00cbm\u00ebhnt\u00ebhtt-R\u00ea should be stored under the heading E\n\u00canio should be stored under the heading E\n\u00e8cole should be stored under the heading E\nEad?eard should be stored under the heading E\nEmma should be stored under the heading E\nEdward should be stored under the heading E\n?fini should be stored under the heading E\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m making the assumption that you are sorting by English collation rules and have alphabetic text. The code below is a good start, but the real world is more complicated than that. (For example, Chinese text has different lexicographic rules depending on the context, e.g. general-purpose dictionary, karaoke song lists, electronic door bell name list, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5979","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5979","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=5979"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5979\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=5979"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=5979"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=5979"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}