in reply to Re^2: RFC: Is this the correct use of Unicode::Collate?
in thread RFC: Is this the correct use of Unicode::Collate?
A "common" practice for handling duplicate names in a database is to append non-printable characters after the name, in the order of insertion. This is like using base 32 (numbers 0 to 31 ) for appended characters. This allows duplicates and retains the order of insertion. You don't have a limit since when you fill the first character, you just add another as "\0" and continue from there. That would be broken with Unicode::Collate.I’m afraid you’ve swapped my implication with your inference, as I implied no such thing — and what you’ve inferred in no way follows from what I wrote. Quoting myself, I wrote:The implication in the article was that you could replace 'sort' with 'Unicode::Collate'.
If you have code that purports to sort text that looks like this:See the red part? Clearly, you do not have ‘code that purports to sort text’! Therefore, nothing I wrote applies to you.@sorted_lines = sort @lines;Then all you have to get a dictionary sort is write instead:use Unicode::Collate; @sorted_lines = Unicode::Collate::->new->sort(@lines);
You have code that blindly does a mindless numeric sort on code points, not an alphabetic sort on text. What you are doing is not an alphabetic sort. Plus sorting of textual representations of numbers is specifically outside the scope of the UCA.
Of course it’s trivial to modify the UCA sort to take care of your weirdo situation, such that it does a proper text sort on the text and a weirdo binary sort on the binary. But you have to tell it to do that. It doesn’t play mind games with you; here as always, one has to know what one is doing, and why.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: RFC: Is this the correct use of Unicode::Collate?
by flexvault (Monsignor) on Jan 17, 2012 at 19:05 UTC |