<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def assemble(self, gboxes, gdefs, theme):
 """ Put together all the guide boxes Parameters gboxes : list List of :class:`~matplotlib.offsetbox.Offsetbox`, where each item is a legend for a single aesthetic. gdefs : list of guide_legend|guide_colorbar guide definitions theme : theme Plot theme Returns ------- box : OffsetBox A box than can be placed onto a plot """

        # place the guides according to the guide.order
        # 0 do not sort
        # 1-99 sort
        for gdef in gdefs:
            if gdef.order == 0:
                gdef.order = 100
            elif not 0 <= gdef.order <= 99:
                raise PlotnineError(
                    "'order' for a guide should be "
                    "between 0 and 99")
        orders = [gdef.order for gdef in gdefs]
        idx = np.argsort(orders)
        gboxes = [gboxes[i] for i in idx]

        # direction when more than legend
        if self.box_direction == 'vertical':
            packer = VPacker
        elif self.box_direction == 'horizontal':
            packer = HPacker
        else:
            raise PlotnineError(
                "'legend_box' should be either "
                "'vertical' or 'horizontal'")

        box = packer(children=gboxes, align=self.box_align,
                     pad=self.box_margin, sep=self.spacing)
        return box