I propose this one:
First, like unutbu, I would use numpy.array to build list
import numpy as np
count_array = np.array([('foo',2),('bar',5),('baz',0)], dtype = np.object)
Then, I sort using operator.itemgetter:
import operator
newlist = sorted(count_array, key=operator.itemgetter(1))
which means: sort count_array w.r.t. argument with index 1, that is the integer value.
Output is
[array([baz, 0], dtype=object), array([foo, 2], dtype=object), array([bar, 5], dtype=object)]
that I can rearrange. I do this with
np.array([list(k) for k in newlist], dtype=np.object)
and I get a numpy array with same format as before
array([[baz, 0],
[foo, 2],
[bar, 5]], dtype=object)
In the end, whole code looks like that
import numpy as np
import operator
count_array = np.array([('foo',2),('bar',5),('baz',0)], dtype = np.object)
np.array([list(k) for k in sorted(count_array, key=operator.itemgetter(1))], dtype=np.object)
with last line doing the requested sort.