public function buildSortClosure($propertyPath, $direction)
    {
        $value = function ($data) use ($propertyPath) {
            return $this->propertyAccessor->getValue($data, $propertyPath);
        };

        if ($direction === Util\ColumnSort::ASC) {
            return function ($rowA, $rowB) use ($value) {
                $a = $value($rowA);
                $b = $value($rowB);

                if ($a == $b) {
                    return 0;
                }

                return $a < $b ? -1 : 1;
            };
        } elseif ($direction === Util\ColumnSort::DESC) {
            return function ($rowA, $rowB) use ($value) {
                $a = $value($rowA);
                $b = $value($rowB);

                if ($a == $b) {
                    return 0;
                }

                return $a > $b ? -1 : 1;
            };
        }

        throw new Exception\InvalidArgumentException("Unexpected column sort direction.");
    }