code: def shuffle_sparse_matrix_and_labels(matrix, labels):
    
    print "Shuffling data"
    new_matrix = matrix.toDense()
    rng_state = numpy.random.get_state()
    numpy.random.shuffle(new_matrix)
    numpy.random.set_state(rng_state)
    numpy.random.shuffle(labels)
  
    print "Data shuffled"
    return SM32(new_matrix), numpy.asarray(labels)
docs: Shuffles a sparse matrix and set of labels together.
    Resorts to densifying and then re-sparsifying the matrix, for
    convenience.  Still very fast.