In your case you don't need to sort at all because you just want an enumerated reversed list of your names:
>>> list(enumerate(names[::-1])) # reverse by slicing
[(0, 'x'), (1, 't'), (2, 'a'), (3, 'd')]
>>> list(enumerate(reversed(names))) # but reversed is also possible
[(0, 'x'), (1, 't'), (2, 'a'), (3, 'd')]
But if you need to sort it then you should use sorted (as provided by @utdemir or @Ulrich Dangel) because it will work on Python2 (zip and itertools.zip) and Python3 (zip) and won't fail with an AttributeError like .sort(...) (which only works on Python2 zip because there zip returns a list):
>>> # Fails with Python 3's zip:
>>> zipped = zip(names, vals)
>>> zipped.sort(lambda x: x[1])
AttributeError: 'zip' object has no attribute 'sort'
>>> # Fails with Python 2's itertools izip:
>>> from itertools import izip
>>> zipped = izip(names, vals)
>>> zipped.sort(lambda x: x[1])
AttributeError: 'itertools.izip' object has no attribute 'sort'
But sorted does work in each case:
>>> zipped = izip(names, vals)
>>> sorted(zipped, key=lambda x: x[1])
[('x', 0), ('t', 1), ('a', 2), ('d', 3)]
>>> zipped = zip(names, vals) # python 3
>>> sorted(zipped, key=lambda x: x[1])
[('x', 0), ('t', 1), ('a', 2), ('d', 3)]
sortedandsort..sort()sorts a list in-place. Andsortedworks on any iterator, but needs to use additional storage to accomplish the task.sortedis consistent with other special python syntax, includingin,len, andreversed, which depend upon the__contains__,__len__, and__getitem__+__len__respectively (I thinksortedneeds__getitem__and__len__but I'm not sure). In many ways, it's also similar to the syntax for[]which is based on__setitem__and__getitem__, or()which initializes__call__. They're builtin functions that translate special internal functions into clear external syntax.