Skip to content

Commit 921e42c

Browse files
authored
Fixed multisort bug
2 parents 5f0b554 + 4ab2956 commit 921e42c

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
- `Fixed` for any bug fixes.
1313
- `Security` in case of vulnerabilities
1414

15+
## [1.3.1] - 2021.03.13
16+
17+
### Fixed
18+
19+
- Fixed bug in `multisort` method to preserve array order by adding the `SORT_NUMERIC` flag.
20+
1521
## [1.3.0] - 2021.02.17
1622

1723
### Added

src/Arr.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public static function undot(array $array): array
8383
* @return void
8484
*/
8585

86-
public static function set(&$array, string $key, $value): void
86+
public static function set(array &$array, string $key, $value): void
8787
{
8888

8989
$keys = explode('.', $key);
@@ -314,11 +314,11 @@ public static function multisort(array $array, string $key, bool $descending = f
314314

315315
if (false === $descending) {
316316

317-
array_multisort($columns, SORT_ASC, $array);
317+
array_multisort($columns, SORT_ASC, $array, SORT_NUMERIC);
318318

319319
} else {
320320

321-
array_multisort($columns, SORT_DESC, $array);
321+
array_multisort($columns, SORT_DESC, $array, SORT_NUMERIC);
322322

323323
}
324324

0 commit comments

Comments
 (0)