Sampling from restricted permutations