private function isValidColumn($name, $contenttype, $allowVariants = false)
    {
        $isValidColumn = false;

        if ($this->isMultiOrderQuery($name)) {
            $separatedOrders = $this->getOrderBys($name);
        } else {
            $separatedOrders = [$name];
        }

        //Loop through each term if multiple
        foreach ($separatedOrders as $index => $name) {
            $name = trim($name);

            // Strip the minus in '-title' if allowed.
            if ($allowVariants) {
                if ((strlen($name) > 0) && ($name[0] == "-")) {
                    $name = substr($name, 1);
                }
                $name = $this->getFieldName($name);
            }

            // Check if the $name is in the contenttype's fields.
            if (isset($contenttype['fields'][$name])) {
                $isValidColumn = true;
            }

            if (in_array($name, Content::getBaseColumns())) {
                $isValidColumn = true;
            }

            // Repeating fields are handled differently so skip here
            if (isset($contenttype['fields'][$name]) && $contenttype['fields'][$name]['type'] == 'repeater') {
                $isValidColumn = false;
            }

            if (! $isValidColumn) {
                return false;
            }
        }

        return true;
    }