1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
<?php
function tocKeysort( $a, $b ){
$aKey = $a['key'] ?: 'H';
$bKey = $b['key'] ?: 'H';
return ord($aKey[0]) - ord($bKey[0]);
}
function tocBooksort( $a, $b ){
$bookOrder = array(
'Genesis',
'Exodus',
'Numbers',
'Deuteronomy',
'Joshua',
'I Samuel',
'I Chronicles',
'II Chronicles',
'Psalm',
'Proverbs',
'Isaiah',
'Jeremiah',
'Lamentations',
'Micah',
'Habakkuk',
'Zephaniah',
'Zepheniah',
'Matthew',
'Matt.',
'John',
'Romans',
'I Cor.',
'II Corinthians',
'Galatians',
'Ephesians',
'Philippians',
'Phil.',
'I Thessalonians',
'II Timothy',
'Hebrews',
'James',
'Psalm',
'I Peter',
'I John',
'Jude',
'Revelation',
'Revelations',
'Rev.',
);
$aVerse = $a['verse'] ?: '';
$bVerse = $b['verse'] ?: '';
$matches = array();
$aBookKey = 3000;
$bBookKey = 3000;
if ( preg_match( '/^[0-9i]*\ ?[A-Z.]+/i', $aVerse, $matches ) ){
$aBook = $matches[0];
$aBookKey = array_search( $aBook, $bookOrder );
}
if ( preg_match( '/^[0-9i]*\ ?[A-Z.]+/i', $bVerse, $matches ) ){
$bBook = $matches[0];
$bBookKey = array_search( $bBook, $bookOrder );
}
return $aBookKey - $bBookKey;
}
|