Stock/Dispatcher/StockAssignmentDispatcher.php
private function sortAssignments(array $assignments, $direction = SORT_DESC)
    {
        usort($assignments, function (StockAssignmentInterface $a, StockAssignmentInterface $b) use ($direction) {
            $aDate = $a->getSaleItem()->getSale()->getCreatedAt();
            $bDate = $b->getSaleItem()->getSale()->getCreatedAt();

            if ($aDate == $bDate) {
                return 0;
            }

            if ($direction === SORT_ASC) {
                return $aDate < $bDate ? -1 : 1;
            }

            return $aDate > $bDate ? -1 : 1;
        });

        return $assignments;
    }
private function sortAssignments(array $assignments, $direction = SORT_DESC)
    {
        usort($assignments, function (StockAssignmentInterface $a, StockAssignmentInterface $b) use ($direction) {
            $aDate = $a->getSaleItem()->getSale()->getCreatedAt();
            $bDate = $b->getSaleItem()->getSale()->getCreatedAt();

            if ($aDate == $bDate) {
                return 0;
            }

            if ($direction === SORT_ASC) {
                return $aDate < $bDate ? -1 : 1;
            }

            return $aDate > $bDate ? -1 : 1;
        });

        return $assignments;
    }
Sort assignments from the most recent to the most ancient.

@param StockAssignmentInterface[] $assignments
@param int                        $direction

@return StockAssignmentInterface[]