We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
array ( 0 => array ( 'item_id' => '240113', 'event_date' => '2023-10-31', ), 1 => array ( 'item_id' => '240113', 'event_date' => '2023-10-30', ), 2 => array ( 'item_id' => '240113', 'event_date' => '2023-10-29', ), )
Sort::by($dataset, static function($element) { return $element['event_date']; });
Sort::byDescending($dataset, static function($element) { return $element['event_date']; });
same result
Sort::user($dataset, static function($first, $second) { return $second['event_date'] <=> $first['event_date']; // return $first['event_date'] <=> $second['event_date']; // doesn't matter, same result });
usort($dataset, static function($first, $second) { return $first['event_date'] <=> $second['event_date']; });
return:
array ( 0 => array ( 'item_id' => '240113', 'event_date' => '2023-10-29', ), 1 => array ( 'item_id' => '240113', 'event_date' => '2023-10-30', ), 2 => array ( 'item_id' => '240113', 'event_date' => '2023-10-31', ), )
as expected
usort($dataset, static function($first, $second) { return $second['event_date'] <=> $first['event_date']; });
returns
As expected too
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Source dataset
After "by Ascending"
After "by Descending":
same result
After user func:
same result
BUT:
return:
as expected
returns
As expected too
The text was updated successfully, but these errors were encountered: