Controller/TemplateController.php
private function getSortedTypes($types = [])
    {
        /** @var Translator $translator */
        $translator = $this->get('translator');
        $locale = $this->getUser()->getLocale();

        $sortedTypes = [];
        $returnTypes = [];

        $i = 0;
        foreach ($types as $alias => $type) {
            $translation = $translator->trans($type->getConfiguration()->getTitle(), [], 'backend', $locale);
            $group = $type->getConfiguration()->getGroup();
            $sortedTypes[$group . '_' . $translation . '_' . $i] = [
                'alias' => $alias,
                'type' => $type,
            ];
            ++$i;
        }

        ksort($sortedTypes);
        foreach ($sortedTypes as $sortedType) {
            $returnTypes[$sortedType['alias']] = $sortedType['type'];
        }

        return $returnTypes;
    }
private function getSortedTypes($types = [])
    {
        /** @var Translator $translator */
        $translator = $this->get('translator');
        $locale = $this->getUser()->getLocale();

        $sortedTypes = [];
        $returnTypes = [];

        $i = 0;
        foreach ($types as $alias => $type) {
            $translation = $translator->trans($type->getConfiguration()->getTitle(), [], 'backend', $locale);
            $group = $type->getConfiguration()->getGroup();
            $sortedTypes[$group . '_' . $translation . '_' . $i] = [
                'alias' => $alias,
                'type' => $type,
            ];
            ++$i;
        }

        ksort($sortedTypes);
        foreach ($sortedTypes as $sortedType) {
            $returnTypes[$sortedType['alias']] = $sortedType['type'];
        }

        return $returnTypes;
    }
@param FormFieldTypeInterface[] $types

@return FormFieldTypeInterface[]