good chemistry is complicated,
and a little bit messy -LW
Reverse Engineering Sort Orderby qq (Hermit)
|on Jun 10, 2003 at 10:42 UTC||Need Help??|
qq has asked for the
wisdom of the Perl Monks concerning the following question:
Hi Reverend Monks:
I want to determine a bi level sort order from a given set of already sorted records for use with Sort::ArbBiLex. (Well, actually a drop in replacement that I've written.)
The existing records are first name, last name have escaped entity sequences in them in the form: é.
I think this might be an interesting problem - but excuse the long post.
Sort::ArbBiLex has a very well written explanation of what bi level sorting is, and why you have to do it.
Decleration format and usage is like:
The decleration form above is just a shorter way of writing an AoA. Its that decleration, or at least a good approximation, that I'm hoping to extract from existing records (see DATA below).
The resulting decleration does not have to be perfect, it will be checked by hand.
Well, if I knew I wouldn't be writing this.
First step, I believe, is to extract a list of glyghs from the data. Since glyghs can be variable widths, you can't do this entirely automatically. For my purposes, since all glyghs longer than one character are easily matched, this is easy. Put them as keys to a hash to remove duplicates (%glyghs below).
Next step I'm lost. I think something like:
but some glyphs are 'equal' on the first level sort. Ie we want an AoA, not just an array. And some glyphs might be invisible to the sort order - ep whitespace or '&rsquo';
Thanks for you're ideas, qq