private function generateSortByPropertyClosure( $property, $direction = SORT_ASC )
    {

        if( $direction === SORT_DESC ) {
            $aLTb = 1;
            $aGTb = -1;
        } else {
            $aLTb = -1;
            $aGTb = 1;
        }

        $mapper = $this->getPropertyMapper($property);

        return function ( $a, $b ) use ( $mapper, $aLTb, $aGTb ) {
            $propertyA = $mapper->get($a);
            $propertyB = $mapper->get($b);
            if( $propertyA === $propertyB ) {
                return 0;
            }
            return ( $propertyA < $propertyB ) ? $aLTb : $aGTb;
        };

    }
private function generateSortByPropertyClosure( $property, $direction = SORT_ASC )
    {

        if( $direction === SORT_DESC ) {
            $aLTb = 1;
            $aGTb = -1;
        } else {
            $aLTb = -1;
            $aGTb = 1;
        }

        $mapper = $this->getPropertyMapper($property);

        return function ( $a, $b ) use ( $mapper, $aLTb, $aGTb ) {
            $propertyA = $mapper->get($a);
            $propertyB = $mapper->get($b);
            if( $propertyA === $propertyB ) {
                return 0;
            }
            return ( $propertyA < $propertyB ) ? $aLTb : $aGTb;
        };

    }
private function generateSortByPropertyClosure ( $ property , $ direction = SORT_ASC ) { if ( $ direction === SORT_DESC ) { $ aLTb = 1 ; $ aGTb = - 1 ; } else { $ aLTb = - 1 ; $ aGTb = 1 ; } $ mapper = $ this -> getPropertyMapper ( $ property ) ; return function ( $ a , $ b ) use ( $ mapper , $ aLTb , $ aGTb ) { $ propertyA = $ mapper -> get ( $ a ) ; $ propertyB = $ mapper -> get ( $ b ) ; if ( $ propertyA === $ propertyB ) { return 0 ; } return ( $ propertyA < $ propertyB ) ? $ aLTb : $ aGTb ; } ; }
Return a user defined sort comparison function that is property mapper aware.
@param string Property to sort on.
@param const SORT_DESC | SORT_ASC Sort direction
@return callable
Return a user defined sort comparison function that is property mapper aware .