protected function createSortTransformFunction()
    {
        $propertyMap = $this->propertyMap;
        $propertyExtractor = $this->getPropertyExtractor();
        $valueChecker = $this->getValueChecker();

        return function($a, $b) use ($propertyMap, $propertyExtractor, $valueChecker){

            foreach($propertyMap as $property){

                $valueA = $propertyExtractor($a, $property['accessor']);
                $valueB = $propertyExtractor($b, $property['accessor']);

                $cmp = $property['comparator'];
                /** @var $cmp ComparatorInterface */

                $valueChecker($valueA, $valueB, $cmp);
                $result = $cmp->compare($valueA, $valueB);

                if($result != 0){
                    return $result * $property['direction'];
                }
            }

            return 0;

        };
    }