def sort_sequence(self, sorted_items, available_items):
        """Prepare objects for edition and start loop.

        Parameters
        ==========
        sorted_items (list or tuple)
            list representing current sorted items.
        available_items (set)
            set representing available items to include
            and sort in the sorted_items sequence.
        """
        ### store type of sorted items
        _type = type(sorted_items)

        ### isntantiate special objects representing the
        ### items to be sorted and the available ones
        self.prepare_objs(sorted_items, available_items)

        ### create flags

        self.cancel = False
        self.running = True

        ### start the widget loop

        while self.running:

            ### perform various checkups for this frame;
            ###
            ### stuff like maintaing a constant framerate and more
            SERVICES_NS.frame_checkups()

            ## perform GUD operations (initials of the
            ## methods; see also the loop holder definition
            ## on the glossary)

            self.handle_input()
            self.update()
            self.draw()

        ### once the loop is exited, return the appropriate
        ### value according to the whether the 'cancel'
        ### flag is set or not

        return (
            ## if the flag is on, return None, indicating
            ## the edition was cancelled
            None
            if self.cancel
            ## otherwise return a sequence with the sorted
            ## values in the type they were received
            else _type(item.value for item in self.items)
        )
Prepare objects for edition and start loop.

        Parameters
        ==========
        sorted_items (list or tuple)
            list representing current sorted items.
        available_items (set)
            set representing available items to include
            and sort in the sorted_items sequence.
        
nodezator/our3rdlibs/sortingeditor/main.py