def stable_sort(some_list, indices=xrange(sys.maxint)): decorated = zip(list,indices) decorated.sort return [item for item, index in decorated]