#! /usr/bin/perl
use warnings;
use strict;
use feature qw{ say };
my %order = (
Numbers => 1,
Psalm => 2,
Matthew => 3,
Luke => 4,
John => 5,
Acts => 6,
'2 Corinthians' => 7,
Ephesians => 8,
Philippians => 9,
Colossians => 10,
Hebrews => 11,
'1 Peter' => 12,
);
sub biblically {
my @info = map [/(.*?) ([0-9]+):([0-9]+)/], $a, $b;
$order{$info[0][0]} <=> $order{$info[1][0]}
||
$info[0][1] <=> $info[1][1]
||
$info[0][2] <=> $info[1][2]
}
my @unsorted = split /\n/, << '__LIST__';
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
__LIST__
my @sorted = sort biblically @unsorted;
say for @sorted;
####
sub biblically {
$order{$a->[0]} <=> $order{$b->[0]}
||
$a->[1] <=> $b->[1]
||
$a->[2] <=> $b->[2]
}
my @sorted = map $_->[-1],
sort biblically
map [/(.*?) ([0-9]+):([0-9]+)/, $_],
@unsorted;
##
##
Ephesians 3:18, 19
Ephesians 3:18-21