From e2f74aab15f9ae779593bb5d35d99a7279e95bf6 Mon Sep 17 00:00:00 2001 From: Robin Kraft Date: Tue, 30 Apr 2019 11:22:59 +0200 Subject: [PATCH] changed sorting to be case insensitive --- README.md | 2 +- .../DingoQueryMapper/Operators/CollectionOperator.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3b0dcc6..22c3634 100644 --- a/README.md +++ b/README.md @@ -104,7 +104,7 @@ will return the next `20` entries that are located on `page 2`. ### `sort` -In order to sort the results using different parameters, you can simply concatenate them using `,`. In order to provide `ASC` and `DESC` sorting, you may prepend a `-` before respective attribute. +In order to sort the results using different parameters, you can simply concatenate them using `,`. In order to provide `ASC` and `DESC` sorting, you may prepend a `-` before respective attribute. Sorting is case-insensitive. For example ```php diff --git a/src/JohannesSchobel/DingoQueryMapper/Operators/CollectionOperator.php b/src/JohannesSchobel/DingoQueryMapper/Operators/CollectionOperator.php index 1edc720..4e79439 100644 --- a/src/JohannesSchobel/DingoQueryMapper/Operators/CollectionOperator.php +++ b/src/JohannesSchobel/DingoQueryMapper/Operators/CollectionOperator.php @@ -68,9 +68,9 @@ private function callbackSearchable($criteria) foreach ($criteria as $c) { // normalize sort direction $orderType = strtolower($c['direction']); - if ($first[$c['column']] < $second[$c['column']]) { + if (strtolower($first[$c['column']]) < strtolower($second[$c['column']])) { return $orderType === "asc" ? -1 : 1; - } elseif ($first[$c['column']] > $second[$c['column']]) { + } elseif (strtolower($first[$c['column']]) > strtolower($second[$c['column']])) { return $orderType === "asc" ? 1 : -1; } }