Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (12)
As of 2015-08-05 11:50 GMT
Find Nodes?
    Voting Booth?

    The oldest computer book still on my shelves (or on my digital media) is ...

    Results (81 votes), past polls