Can't you just .replace()
the values?
df.sort(pl.col("a").replace(l, range(len(l))))
shape: (5, 2)
┌─────┬─────┐
│ a ┆ b │
│ --- ┆ --- │
│ i64 ┆ str │
╞═════╪═════╡
│ 1 ┆ x │
│ 3 ┆ z │
│ 5 ┆ f │
│ 2 ┆ y │
│ 4 ┆ p │
└─────┴─────┘