'Make row order align with key order.'

def sort(self):

    if self.unique:
        for (i, (key, row)) in enumerate(self.data.items()):
            self.data[key] = i
    else:
        i = 0
        for (key, rows) in self.data.items():
            num_rows = len(rows)
            self.data[key] = [x for x in range(i, (i + num_rows))]
            i += num_rows
