Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Re: Re: Dictionary-style sort a la Tcl?

by Juerd (Abbot)
on Apr 18, 2002 at 15:22 UTC ( #160225=note: print w/ replies, xml ) Need Help??


in reply to Re: Re: Dictionary-style sort a la Tcl?
in thread Dictionary-style sort a la Tcl?

hat's a Schwartzian Transform, right?

It is. In short: by creating a datastructure that you store together with the original string, you don't have to re-build the original string and don't have to take apart the string at every iteration.

After replacing $A =~ /\D/ || $B =~ /\D/ with $A !~ /\d+/ || $B !~ /\d+/ (is there a better way?), it worked.

Your correction was correct. You can actually even drop the plusses. I'll update my code right away.

I am, however, wondering about "1abc" coming before "123DEF" (and the other "123...")

As I see it, that is correct. Integers should be used as such, according to your definition. That was the challenge :) First, the string is split to integer and non-integer parts, and then they are compared to eachother.

out of (1, abc) and (123, DEF), the first wins because 1 < 123.

- Yes, I reinvent wheels.
- Spam: Visit eurotraQ.


Comment on Re: Re: Re: Dictionary-style sort a la Tcl?

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (10)
As of 2014-07-11 06:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (219 votes), past polls