### Convert between different ways of expressing permutations

Suppose I have two permutations x and y, given in one line notation (e.g. x=[2,1,4,3] and y=[3,2,1,4]). How would I go about computing e.g. the Kazhdan-Lusztig polynomial P_{x,y}(q) in sage? The KL polynomial requires as input representing symmetric group elements as products of simple reflections and I do not know how to (using a computer) convert between these different ways of expressing a permutation. How does one do this in sage?