<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _restricted_growth_notation(l):
 """ The clustering returned by the hcluster module gives group membership without regard for numerical order This function preserves the group membership, but sorts the labelling into numerical order """


        list_length = len(l)

        d = defaultdict(list)
        for (i, element) in enumerate(l):
            d[element].append(i)

        l2 = [None] * list_length

        for (name, index_list) in enumerate(sorted(d.values(), key=min)):
            for index in index_list:
                l2[index] = name

        return tuple(l2)