private function sortDraftCollection(array $drafts)
    {
        $sortedDrafts = [];
        $filteredDrafts = [];

        foreach ($drafts as $draft) {
            if (null === $draft->getContent()) {
                continue;
            }

            $sortedDrafts[$draft->getContent()->getUid()] = [$draft->getContent()->getUid() => $draft];
        }

        foreach ($drafts as $draft) {
            foreach ($draft->getContent()->getData() as $key => $element) {
                if (
                    !is_int($key)
                    && $element instanceof AbstractClassContent
                    && in_array($element->getUid(), array_keys($sortedDrafts))
                ) {
                    $elementUid = $element->getUid();
                    $sortedDrafts[$draft->getContent()->getUid()][$key] = $sortedDrafts[$elementUid][$elementUid];
                }
            }
        }

        foreach ($sortedDrafts as $key => $data) {
            foreach ($data as $elementName => $draft) {
                if ($key === $elementName) {
                    continue;
                }

                if (isset($sortedDrafts[$draft->getContent()->getUid()])) {
                    $sortedDrafts[$key][$elementName] = &$sortedDrafts[$draft->getContent()->getUid()];
                    $filteredDrafts[$draft->getContent()->getUid()] = false;
                }
            }
        }

        return array_filter(array_merge($sortedDrafts, $filteredDrafts));
    }