Skip to content

why _\filter also sort passed list not only filter? #14

@r-kuribayashi

Description

@r-kuribayashi

lodash-php/src/Collection/filter.php l.65

function filter(iterable $array, $predicate = null): array
{
    $iteratee = baseIteratee($predicate);
    $result = \array_filter(
        \is_array($array) ? $array : \iterator_to_array($array),
        function ($value, $key) use ($array, $iteratee) {
            return $iteratee($value, $key, $array);
        },
        \ARRAY_FILTER_USE_BOTH
    );
    \sort($result); // <- why ?
    return $result;
}

why _\filter also sort list not only filter?

it confuse me because I don't expected "filtered list is sorted".
when i need the sorted, i want to do by myself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions