good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Re: Sorting on Section Numbersby athomason (Curate) |
on Jul 28, 2000 at 03:24 UTC ( [id://24777]=note: print w/replies, xml ) | Need Help?? |
Fundamentally, you want to split on both dots and number-letter borders. Fortunately, split can be told to return its delimiters by including parentheses around the matching class. By doing that, you'll also need to get rid of the periods it matches with grep. So, this should split up arbitrarily nested section titles.
Your sort then just needs to have a function which splits up the entries and compares them.
You should avoid repeatedly splitting the lists by caching the split results. There may be an error stuck somewhere in here; my test set was just what is in the above code. Hope this works for you.
In Section
Seekers of Perl Wisdom
|
|