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)