-
-
Notifications
You must be signed in to change notification settings - Fork 66
/
sort_by.php
30 lines (26 loc) 路 802 Bytes
/
sort_by.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
declare(strict_types=1);
namespace Psl\Arr;
use Psl\Vec;
/**
* Returns a new list sorted by some scalar property of each value of the given
* iterable, which is computed by the given function.
*
* If the optional comparator function isn't provided, the values will be sorted
* in ascending order of scalar key.
*
* @psalm-template Tv
* @psalm-template Ts
*
* @psalm-param iterable<Tv> $iterable
* @psalm-param (callable(Tv): Ts) $scalar_func
* @psalm-param (callable(Ts, Ts): int)|null $comparator
*
* @psalm-return list<Tv>
*
* @deprecated since 1.2, use Vec\sort_by instead.
*/
function sort_by(iterable $iterable, callable $scalar_func, ?callable $comparator = null): array
{
return Vec\sort_by($iterable, $scalar_func, $comparator);
}