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.