public static function generateByPropertyClosure( $property, $direction = SORT_ASC )
    {

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

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

    }
public static function generateByPropertyClosure( $property, $direction = SORT_ASC )
    {

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

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

    }
public static function generateByPropertyClosure ( $ property , $ direction = SORT_ASC ) { if ( $ direction === SORT_DESC ) { $ aLTb = 1 ; $ aGTb = - 1 ; } else { $ aLTb = - 1 ; $ aGTb = 1 ; } return function ( \ Bond \ Entity \ Base $ a , \ Bond \ Entity \ Base $ b ) use ( $ property , $ aLTb , $ aGTb ) { $ propertyA = $ a -> get ( $ property ) ; $ propertyB = $ b -> get ( $ property ) ; if ( $ propertyA === $ propertyB ) { return 0 ; } return ( $ propertyA < $ propertyB ) ? $ aLTb : $ aGTb ; } ; }
Generate a sort by property callback
@param string $property property to sort by
Generate a sort by property callback