Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Reverse Engineering Sort Order

by BrowserUk (Patriarch)
on Jun 10, 2003 at 11:58 UTC ( [id://264640]=note: print w/replies, xml ) Need Help??


in reply to Reverse Engineering Sort Order

Thanks for you're ideas

I've read your post 4 times now, I'm afraid I'm still not sure quite what your question is?

I think a simple example of "given this input, I would like a routine that produces this output" would be a good starting point.

Oh, and sometimes, less is more:)


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller


Replies are listed 'Best First'.
Re: Re: Reverse Engineering Sort Order
by zby (Vicar) on Jun 10, 2003 at 13:02 UTC
    I did this rereading excercise too - but eventually I think I know what he needs. He has a sorted list of records and he want's to determine what kind of sort was used to sort it.

    More precisely he has a definition of a family of sorting functions, and the result of applying one of those functions to some data record. He want's to determine what was that function.

    Perhaps he want's an algorithm that given the sorted list would output the definition of the sorting function.

      Thats about it. The original data is hand sorted. I want to know what rules, or rather character order, was used to sort it.

Re: Re: Reverse Engineering Sort Order
by qq (Hermit) on Jun 10, 2003 at 17:49 UTC

    less is more

    Sorry about that - I didn't want to put a hard problem before you without showing that I had at least begun to think about it.

    So, given the input in the original posts __DATA__, I'm trying to extract a decleration for use with Sort::ArbBiLex, so that, if the original records lose their ordering, I could resort them.

      I think the problem was more mine than yours. zby managed to work out what you were asking, as evidenced by

      Perhaps he want's an algorithm that given the sorted list would output the definition of the sorting function.

      But no matter how many times I read it, I didn't get your drift.

      However, since then I have given the problem some pretty serious thunking, and I'm really not sure that what your asking is possible. Leastwise, not if your after complete accuracy unless you have a very large sample set that reflects all the possible comparisons. Even then, there is another, trickier problem.

      Lets assume somewhere in your dataset you had

      cuerno chile

      According to the POD for Sort::ArbBiLex, in a spanish dictionary, cuerno sorts before chile, because the 'ch' in chile, is considered a "single glyph" that sorts after the single glyph 'c' in cuerno.

      The problem is, whos to says that there isn't a language where the second glyph in cuerno is 'ue', and that this is designated as sorting before the second glyph in chile, 'h'?

      I simply cannot see any mechanistic way of making the determination of when 2 character codes represent a single glyph. It strikes me that the only way to do this is heuristically, and that means that you would have to already know what pairs consituted single glyphs up front.

      I don't envy you the problem, but if you do solve it, I'd be very interested to see how you do it.

      Good luck:)


      Examine what is said, not who speaks.
      "Efficiency is intelligent laziness." -David Dunham
      "When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller


        I agree. In my original post I mention that the first step would be to get a list of glyphs, which would probably require manual intervention. (Although not in the simple case where all multi-character glyphs are escaped)

        But even if the glyphs are known I can't see how to go forward.

        I'm also not necessarily trying for a perfect solution.

        btw, I take to heart youre less is more comment. I think the problem could have been much more clearly presented, and I will try to do so in the future.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://264640]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (7)
As of 2024-04-19 07:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found