def get_alphabetical_insert_position(self, new_menu_name, item_type,
                                         default=0):
        results = self.find_items(item_type)

        # No items yet? Use the default value provided
        if not len(results):
            return default

        last_position = 0

        for result in sorted(results, key=lambda x: x.item.name):
            if result.item.name > new_menu_name:
                return result.index

            if result.index > last_position:
                last_position = result.index
        else:
            return last_position + 1
dataset/ETHPy150Open divio/django-cms/cms/toolbar/items.py/ToolbarAPIMixin.get_alphabetical_insert_position/original