Skip to content

Commit be9ba73

Browse files
update
1 parent 8b8bf46 commit be9ba73

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

Str.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ static public function last($array = null)
5656
* @param string $type
5757
* - [rsort|asort|ksort|arsort|krsort|sort]
5858
*
59-
* @return void
59+
* @return array
6060
*/
6161
static public function sortArray(?array &$data = [], ?string $type = 'sort')
6262
{
63-
Tame::sortArray($data, $type);
63+
return Tame::sortArray($data, $type);
6464
}
6565

6666
/**
@@ -71,11 +71,11 @@ static public function sortArray(?array &$data = [], ?string $type = 'sort')
7171
* @param string $type
7272
* - [asc|desc|snum]
7373
*
74-
* @return void
74+
* @return array
7575
*/
7676
static public function sortMultipleArray(?array &$data = [], $key = null, ?string $type = 'asc')
7777
{
78-
Tame::sortMultipleArray($data, $key, $type);
78+
return Tame::sortMultipleArray($data, $key, $type);
7979
}
8080

8181
/**

Tame.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -547,13 +547,13 @@ static public function isArraySame(?array $data = [])
547547
* @param string $type
548548
* - [rsort|asort|ksort|arsort|krsort|sort]
549549
*
550-
* @return void
550+
* @return array
551551
*/
552552
static public function sortArray(?array &$data = [], ?string $type = 'sort')
553553
{
554554
// Validate that $data is an array
555555
if (!is_array($data)) {
556-
return;
556+
return [];
557557
}
558558

559559
// Perform sorting based on the specified type
@@ -582,6 +582,8 @@ static public function sortArray(?array &$data = [], ?string $type = 'sort')
582582
sort($data); // Sort arrays in ascending order
583583
break;
584584
}
585+
586+
return $data;
585587
}
586588

587589
/**
@@ -592,19 +594,19 @@ static public function sortArray(?array &$data = [], ?string $type = 'sort')
592594
* @param string $type
593595
* - [asc|desc|snum]
594596
*
595-
* @return void
597+
* @return array
596598
*/
597599
static public function sortMultipleArray(?array &$data = [], $key = null, ?string $type = 'asc')
598600
{
599601
// Check if $data is an array and not empty
600602
if (!is_array($data) || empty($data)) {
601-
return;
603+
return [];
602604
}
603605

604606
// Check if $key is provided
605-
if ($key === null) {
606-
// If $key is not provided, return without sorting
607-
return;
607+
// If $key is not provided, return without sorting
608+
if (is_null($key)) {
609+
return $data;
608610
}
609611

610612
// Extract values of the specified key from each sub-array
@@ -628,6 +630,8 @@ static public function sortMultipleArray(?array &$data = [], $key = null, ?strin
628630
array_multisort($id, SORT_ASC, $data); //sort arrays in ascending order
629631
break;
630632
}
633+
634+
return $data;
631635
}
632636

633637
/**

0 commit comments

Comments
 (0)