in reply to Funky sorting

We needed to address nesting of string values as well as regular ordering
I don't understand what you mean by this. It looks like you're just sorting on the length of the string. Replacing your big for loop with the following line produces the same output.
@v = sort {length($a) <=> length($b)} @v;

Replies are listed 'Best First'.
(tye)Re: Funky sorting
by tye (Sage) on Nov 10, 2001 at 04:44 UTC

    Yeah, that index threw me for quite a while. I think a more accurate replacement is:

    @v= sort { length($a) <=> length($b) || $a cmp $b } @v;
    however (sort first by length and sort strings of the same length lexigraphically).

    Basically, the use of index doesn't end up changing anything since $a can only be a substring of $b if it is either shorter than $b or it is exactly equal to $b.

            - tye (but my friends call me "Tye")
      Ah, you're right. For some reason I thought the data being sorted would never tie, but that is obviously wrong. (The first "elements" got magically sorted in my head.... meaning length was the only defining characteristic. i.e. two strings starting with same two digits and having the same length are equal by construction.)

      -Blake

      So basically I've been sitting here overcomplicating things. Damn.

      Thanks