def METHOD_NAME(self):
    if self.grouping_pattern:
        last_groupid = ""
        grouping_index = 0
        grouping_range = 1000
        for idx, item in enumerate(self.items_list):
            match = re.search(self.grouping_pattern, item.number)
            if match and match.groups():
                groupid = match.groups()[0]
                if groupid != last_groupid:
                    last_groupid = groupid
                    grouping_index += 1
                item.order_index = (grouping_range * grouping_index) + idx
            else:
                item.order_index = idx
    else:
        for idx, item in enumerate(self.items_list):
            item.order_index = idx