Once you have extracted the book and the chapter, you can translate the two together into a single number by multiplying the book rank by 10000 say plus the chapter. Now use the Schwartzian to sort the citations:

use strict; use warnings; my $ctr=0; my %books=map{$_=>++$ctr}( 'Genesis','Exodus','Leviticus','Numbers','Deuteronomy','Joshua', 'Judges','Ruth','1 Samuel','2 Samuel','1 Kings','2 Kings', '1 Chronicles','2 Chronicles','Ezra','Nehemiah','Esther', 'Job','Psalm','Proverbs','Ecclesiastes','Song of Solomon', 'Isaiah','Jeremiah','Lamentations','Ezekiel','Daniel', 'Hosea','Joel','Amos','Obadiah','Jonah','Micah','Nahum', 'Habakkuk','Zephaniah','Haggai','Zechariah','Malachi', 'Matthew','Mark','Luke','John','Acts','Romans','1 Corinthians', '2 Corinthians','Galatians','Ephesians','Philippians', 'Colossians','1 Thessalonians','2 Thessalonians','1 Timothy', '2 Timothy','Titus','Philemon','Hebrews','James','1 Peter', '2 Peter','1 John','2 John','3 John','Jude','Revelation'); my @sorted= map{$_->[0]} sort{$a->[1]<=>$b->[1]} map{chomp;/^(\d?\s?\w+)\s+(\d+)/;[$_,10000*$books{$1}+$2]} <DATA>; print "$_\n" for @sorted; __DATA__ Acts 4:29-31 Numbers 14:10 Luke 1:20 John 16:15 Acts 2:4 1 Peter 1:22 Psalm 56:3 2 Corinthians 12:2, 4, 1, 11 Ephesians 3:18, 19 Ephesians 4:14, 13, 17, 18; 5:15, 16 Matthew 24:24 Colossians 2:6-8 Hebrews 10:35-39 Hebrews 4:10-12 Philippians 1:6, 27-29 Matthew 7:6-12, 15 Philippians 2:13-15

In reply to Re: Regex Substring SORT Conundrum by hdb
in thread Regex Substring SORT Conundrum by Polyglot

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.