linearExtensions[set_, po_] :=
Module[{patterns},
patterns = {___, #[[1]], ___, #[[2]], ___}& /@ po;
First[NestWhile[First@NestWhile[{Cases[#[[1]], First[#[[2]]]], Rest[#[[2]]]}&,
Rest[#[[2]]]} &, {Permutations[set], patterns}, Length[#[[2]]] > 0&]]0&]
]
My second approach, which turned out to be significantly slower, was to expand a set of rules from the partial order and use selectSelect
on the list of permutations.