more useful options PerlMonks

### Re: (turnstep) Sorting on Section Numbers

by turnstep (Parson)
 on Jul 28, 2000 at 22:05 UTC ( #24943=note: print w/replies, xml ) Need Help??

in reply to Sorting on Section Numbers

Here is my version. I *think* it should work for all cases. I'll break it down if anyone is curious.

```@sorted =
map { \$_->[0] }
sort {
\$x=1;
while (defined \$a->[1][\$x]) {
defined \$b->[1][\$x] or return -1;
if (\$x%2) { ## Strict numeric comparison
return 1  if \$a->[1][\$x] > \$b->[1][\$x];
return -1 if \$a->[1][\$x] < \$b->[1][\$x];
}
else { ## Non-numeric comparison
return 1  if \$a->[1][\$x] gt \$b->[1][\$x];
return -1 if \$a->[1][\$x] lt \$b->[1][\$x];
}
\$x++;
}
return defined \$b->[1][\$x] ? 1 : 0;
}
map { [\$_, [split(/(\d+)/, \$_)]] }
@unsorted;

Create A New User
Node Status?
node history
Node Type: note [id://24943]
help
Chatterbox?
 holli gotta grab some groceries before dawn. l8ters [erix]: s/dawn/dusk/ [erix]: (you're welcome :P) [james28909]: you know, i had a thought a few mnths back. what if this universe were just a puzzle, waiting for life to figure it out! [james28909]: what if one day we are able to grab the curtain that is "spacetime" and pull it back to reveal pulling at levers and ropes xD [holli]: like dorothy? [james28909]: see ya later holli [james28909]: yeah like wizard of oz lol. its just a joke though [james28909]: i cannot understand how someone cant see that a cloud of gas that evolves into a solar system or galaxies. it just makes sense to me. everythign that has happened, had to have happened for anything on this planet to be. [james28909]: /gas/gas and debris/

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (14)
As of 2017-12-15 14:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
What programming language do you hate the most?

Results (433 votes). Check out past polls.

Notices?