public function sortSecondaryKeys($primaryKey, array $order = null)
    {
        if (!isset($this->values[$primaryKey])) {
            throw new OutOfBoundsException(sprintf(
                'The key "%s" does not exist.',
                $primaryKey
            ));
        }

        if (!$order) {
            ksort($this->values[$primaryKey]);

            return;
        }

        $orderedKeys = array_intersect_key(array_flip($order), $this->values[$primaryKey]);

        $this->values[$primaryKey] = array_replace($orderedKeys, $this->values[$primaryKey]);
    }