def sort_items(self, sorting_callable):
        """Sort items w/ callable and reposition them.

        Parameters
        ==========
        sorting_callable (callable)
            callable used to sort the items.
        """
        ### sorting makes no sense when there aren't any
        ### items, so we return early
        if not self.items:
            return

        ### otherwise we proceed realigning and repositioning
        ### the items

        ## backup topleft
        topleft = self.items.rect.topleft

        ## sort items
        sorting_callable(self.items)

        ## reposition items relative to each other

        self.items.rect.snap_rects_ip(
            retrieve_pos_from="topright", assign_pos_to="topleft", offset_pos_by=(5, 0)
        )

        ## restore topleft
        self.items.rect.topleft = topleft
Sort items w/ callable and reposition them.

        Parameters
        ==========
        sorting_callable (callable)
            callable used to sort the items.
        
nodezator/our3rdlibs/sortingeditor/main.py