From ca487901c2e787a04f4ed029e48e900b721cb555 Mon Sep 17 00:00:00 2001 From: "Timothy J. Warren" Date: Mon, 5 Nov 2018 10:40:29 -0500 Subject: [PATCH] Sort streaming links by service --- src/API/Kitsu.php | 4 ++++ src/Controller/User.php | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/API/Kitsu.php b/src/API/Kitsu.php index 6814d2fc..83a9737b 100644 --- a/src/API/Kitsu.php +++ b/src/API/Kitsu.php @@ -163,6 +163,10 @@ final class Kitsu { 'dubs' => $streamingLink['dubs'] ]; } + + usort($links, function ($a, $b) { + return $a['meta']['name'] <=> $b['meta']['name']; + }); return $links; } diff --git a/src/Controller/User.php b/src/Controller/User.php index 3cf8f855..2780542f 100644 --- a/src/Controller/User.php +++ b/src/Controller/User.php @@ -94,16 +94,16 @@ final class User extends BaseController { /** * Reorganize favorites data to be more useful * - * @param array $rawfavorites + * @param array $rawFavorites * @return array */ - private function organizeFavorites(array $rawfavorites): array + private function organizeFavorites(array $rawFavorites): array { $output = []; - unset($rawfavorites['data']); + unset($rawFavorites['data']); - foreach ($rawfavorites as $item) + foreach ($rawFavorites as $item) { $rank = $item['attributes']['favRank']; foreach ($item['relationships']['item'] as $key => $fav)