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.");
    }
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.");
    }
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." ) ; }
Builds the sort closure.

@param string $propertyPath
@param string $direction

@return \Closure
Builds the sort closure .