for i in range(m.shape[0]):
    d = m.getrow(i)
n = len(d.indices)
s = zip([i] * n, d.indices, d.data)
sorted_s = sorted(s, key=lambda v: v[2], reverse=True)
a.extend(sorted_s)
a = np.array(a)
new_m = coo_matrix((a[:, (2)], (a[:, (0)], a[:, (1)])), m.shape)
Sorting in Sparse Matrix