Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://160225]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2018-03-17 15:40 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (224 votes). Check out past polls.