From 72ca6103f971e321c9c3240372fff8376e28ec6b Mon Sep 17 00:00:00 2001 From: Luke Denton Date: Tue, 17 Apr 2018 12:38:36 +0930 Subject: [PATCH 1/3] Fixed the return value from the usort custom sort function The return value from the function now lines up with the PHP documentation for the usort comparator function --- app/code/Magento/Customer/Block/Account/Navigation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Customer/Block/Account/Navigation.php b/app/code/Magento/Customer/Block/Account/Navigation.php index cb38d762769f2..afce0df7b259d 100644 --- a/app/code/Magento/Customer/Block/Account/Navigation.php +++ b/app/code/Magento/Customer/Block/Account/Navigation.php @@ -46,6 +46,6 @@ public function getLinks() */ private function compare(SortLinkInterface $firstLink, SortLinkInterface $secondLink) { - return ($firstLink->getSortOrder() < $secondLink->getSortOrder()); + return ($firstLink->getSortOrder() < $secondLink->getSortOrder()) ? -1 : 1; } } From 39202ba7c64724a37cbf675ea61eb0ceee7b40e9 Mon Sep 17 00:00:00 2001 From: Luke Denton Date: Tue, 17 Apr 2018 12:42:44 +0930 Subject: [PATCH 2/3] Added check for equality to return 0 This now covers all possible situations, returning a value that the usort function expects --- app/code/Magento/Customer/Block/Account/Navigation.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/code/Magento/Customer/Block/Account/Navigation.php b/app/code/Magento/Customer/Block/Account/Navigation.php index afce0df7b259d..127d21c5bbd43 100644 --- a/app/code/Magento/Customer/Block/Account/Navigation.php +++ b/app/code/Magento/Customer/Block/Account/Navigation.php @@ -46,6 +46,10 @@ public function getLinks() */ private function compare(SortLinkInterface $firstLink, SortLinkInterface $secondLink) { + if ($firstLink->getSortOrder() == $secondLink->getSortOrder()) { + return 0; + } + return ($firstLink->getSortOrder() < $secondLink->getSortOrder()) ? -1 : 1; } } From 727709bfba4951e4dca4be18cf10475e7e81970f Mon Sep 17 00:00:00 2001 From: Volodymyr Zaets Date: Tue, 24 Apr 2018 14:08:31 +0300 Subject: [PATCH 3/3] Fix/navigation order function --- app/code/Magento/Customer/Block/Account/Navigation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Customer/Block/Account/Navigation.php b/app/code/Magento/Customer/Block/Account/Navigation.php index 127d21c5bbd43..64ced9d592e11 100644 --- a/app/code/Magento/Customer/Block/Account/Navigation.php +++ b/app/code/Magento/Customer/Block/Account/Navigation.php @@ -50,6 +50,6 @@ private function compare(SortLinkInterface $firstLink, SortLinkInterface $second return 0; } - return ($firstLink->getSortOrder() < $secondLink->getSortOrder()) ? -1 : 1; + return ($firstLink->getSortOrder() < $secondLink->getSortOrder()) ? 1 : -1; } }