Most effiecient way to move padding tokens to the right side of a tensor?

Hi, I was wondering the most efficient way to move the padding tokens in a given tensor to the rightmost? A more concrete example is illustrated below.

Suppose the padded tensor is the following one.

x = [
    [PAD, X, X, X, PAD],
    [PAD, PAD, X, X, X],
    [X, X, X, X, X]
]

I’d like the output to be:

x = [
    [X, X, X, PAD, PAD],
    [X, X, X, PAD, PAD],
    [X, X, X, X, X]
]

Thanks in advance for your help!