random_data = [(4, 'd'), (1, 'a'), (3, 'c'), (2, 'b')]
data_items = []
for index, data_value in random_data:
    data_items.append((index, data_value))
data_items.sort()
indices, data = zip(*data_items)
indices
data
Out of bounds assignment to a python array - am I reinventing a wheel?