This is going to be painful, but using default python you have 2 options:
decorate the 3rd list1st and 2nd lists with
enumerate(), then sort, then sort the other lists based on these using the extra index. to refer to values from the 3rd list:cat_sorted = [ [e for i, e in sorted(enumerate(cat[0]), key=lambda p: cat[2][p[0]])], [e for i, e in sorted(enumerate(cat[1]), key=lambda p: cat[2][p[0]])], sorted(cat[2]) ]
although it may help to sort cat[2] in-place instead of using sorted(); you cannot get around using sorted() for the other two.
zip()the three lists together, then sort on the third element of this new list of lists, thenzip()again to get back to the original structure:from operator import itemgetter cat_sorted = zip(*sorted(zip(*cat), key=itemgetter(2)))
Neither will be a performance buster, not with plain python lists of millions of numbers.