Backend for songs.zachdecook.com
* Table of contents: add title sort
Zach DeCook 2018-03-20
parent 316c95c · commit c48449a
-rw-r--r--page.php3
-rw-r--r--sort.php5
2 files changed, 8 insertions, 0 deletions
diff --git a/page.php b/page.php
index 94d0317..4213f0b 100644
--- a/page.php
+++ b/page.php
@@ -50,6 +50,9 @@ function toc( $sort ){
else if ( $sort == 'verse' ){
usort( $entries, 'tocBooksort' );
}
+ else if ( $sort == 'title' ){
+ usort( $entries, 'tocTitlesort' );
+ }
}
foreach( $entries as $item ){
$toc .= tocentry($item);
diff --git a/sort.php b/sort.php
index ab72d49..6e24273 100644
--- a/sort.php
+++ b/sort.php
@@ -6,6 +6,11 @@ function tocKeysort( $a, $b ){
return ord($aKey[0]) - ord($bKey[0]);
}
+function tocTitleSort( $a, $b ){
+ $aTitle = $a['title'];
+ $bTitle = $b['title'];
+ return strcmp( $aTitle, $bTitle );
+}
function tocBooksort( $a, $b ){
$bookOrder = array(