protected function setDefaultComparator()
    {
        $func = function($a, $b)
        {
            $temp = 0;
            $cmpres = null;
            foreach($this->orders as $order)
            {
                $valuea = call_user_func($order['property'], $a);
                $valueb = call_user_func($order['property'], $b);

                if($valuea instanceof \DateTime || $valueb instanceof \DateTime ||
                      is_numeric($valuea) || is_numeric($valueb))
                {
                   if(is_numeric($valuea) || is_numeric($valueb))
                   {
                      $valuea = ((double)$valuea);
                      $valueb = ((double)$valueb);
                   }
                   $cmpres = ($valuea < $valueb ? -1 : ($valuea > $valueb ? 1 : 0));
                }
                else
                {
                   $cmpres = strcmp($valuea, $valueb);
                }

                $temp = (($order['direction'] == self::ORDER_DESC) ? -1 : 1) * $cmpres;
                if($temp!=0)
                {
                    break;
                }
            }
            return $temp;
        };

        $this->setComparator($func);
    }
protected function setDefaultComparator()
    {
        $func = function($a, $b)
        {
            $temp = 0;
            $cmpres = null;
            foreach($this->orders as $order)
            {
                $valuea = call_user_func($order['property'], $a);
                $valueb = call_user_func($order['property'], $b);

                if($valuea instanceof \DateTime || $valueb instanceof \DateTime ||
                      is_numeric($valuea) || is_numeric($valueb))
                {
                   if(is_numeric($valuea) || is_numeric($valueb))
                   {
                      $valuea = ((double)$valuea);
                      $valueb = ((double)$valueb);
                   }
                   $cmpres = ($valuea < $valueb ? -1 : ($valuea > $valueb ? 1 : 0));
                }
                else
                {
                   $cmpres = strcmp($valuea, $valueb);
                }

                $temp = (($order['direction'] == self::ORDER_DESC) ? -1 : 1) * $cmpres;
                if($temp!=0)
                {
                    break;
                }
            }
            return $temp;
        };

        $this->setComparator($func);
    }
protected function setDefaultComparator ( ) { $ func = function ( $ a , $ b ) { $ temp = 0 ; $ cmpres = null ; foreach ( $ this -> orders as $ order ) { $ valuea = call_user_func ( $ order [ 'property' ] , $ a ) ; $ valueb = call_user_func ( $ order [ 'property' ] , $ b ) ; if ( $ valuea instanceof \ DateTime || $ valueb instanceof \ DateTime || is_numeric ( $ valuea ) || is_numeric ( $ valueb ) ) { if ( is_numeric ( $ valuea ) || is_numeric ( $ valueb ) ) { $ valuea = ( ( double ) $ valuea ) ; $ valueb = ( ( double ) $ valueb ) ; } $ cmpres = ( $ valuea < $ valueb ? - 1 : ( $ valuea > $ valueb ? 1 : 0 ) ) ; } else { $ cmpres = strcmp ( $ valuea , $ valueb ) ; } $ temp = ( ( $ order [ 'direction' ] == self :: ORDER_DESC ) ? - 1 : 1 ) * $ cmpres ; if ( $ temp != 0 ) { break ; } } return $ temp ; } ; $ this -> setComparator ( $ func ) ; }
Set the default compare method
Set the default compare method