code: def ungroup_gen(grouped_items, groupxs, fill=None):
      import utool as ut
      minpergroup = [min(xs) if len(xs) else 0 for xs in groupxs]
      minval = min(minpergroup) if len(minpergroup) else 0
      flat_groupx = ut.flatten(groupxs)
      sortx = ut.argsort(flat_groupx)
      groupx_sorted = ut.take(flat_groupx, sortx)
      flat_items = ut.iflatten(grouped_items)
      toyeild = {}
      items_yeilded = 0
      current_index = 0
      num_fills_before = [minval] + (np.diff(groupx_sorted) - 1).tolist() + [0]
      fills = num_fills_before[items_yeilded]
      if fills > 0:
          for _ in range(fills):
              yield None
              current_index += 1
      for yeild_at, item in zip(flat_groupx, flat_items):
          if yeild_at > current_index:
              toyeild[yeild_at] = item
          elif yeild_at == current_index:
              yield item
              current_index += 1
              items_yeilded += 1
              fills = num_fills_before[items_yeilded]
              if fills > 0:
                  for _ in range(fills):
                      yield None
                      current_index += 1
              while current_index in toyeild:
                  item = toyeild.pop(current_index)
                  yield item
                  current_index += 1
                  items_yeilded += 1
                  fills = num_fills_before[items_yeilded]
                  if fills > 0:
                      for _ in range(fills):
                          yield None
                          current_index += 1