diff --git a/lib/Library.php b/lib/Library.php index cd947486..2902b24f 100644 --- a/lib/Library.php +++ b/lib/Library.php @@ -140,12 +140,21 @@ class Library{ } /** - * @return array + * @return array * @throws Exceptions\AppException */ public static function GetEbookCollections(): array{ - /** @var array */ - return self::GetFromApcu('collections'); + $collections = Db::Query(' + SELECT distinct UrlName, Name + from Collections + ', [], Collection::class); + + $collator = Collator::create('en_US'); + if($collator === null){ + throw new Exceptions\AppException('Couldn\'t create collator object when getting collections.'); + } + usort($collections, function($a, $b) use($collator){ return $collator->compare($a->GetSortedName(), $b->GetSortedName()); }); + return $collections; } /**