Partial order optimality theory (PoOT) (Anttila and Cho in Lingua 104:31---56, 1998) is a conservative generalization of classical optimality theory (COT) (Prince and Smolensky in Optimality theory: constraint interaction in generative grammar, Blackwell Publishers, Malden, 1993/2004) that makes possible the modeling of free variation and quantitative regularities without any numerical parameters. Solving the ranking problem for PoOT has so far remained an outstanding problem: allowing for free variation, given a finite set of input/output pairs, i.e., a dataset, $$\Delta $$Δ that a speaker S knows to be part of some language L, how can S learn the set of all grammars G under some constraint set C compatible with $$\Delta $$Δ?. Here, allowing for free variation, given the set of all PoOT grammars GPoOT over a constraint set C , for an arbitrary $$\Delta $$Δ, I provide set-theoretic means for constructing the actual set G compatible with $$\Delta $$Δ. Specifically, I determine the set of all STRICT ORDERS of C that are compatible with $$\Delta $$Δ. As every strict total order is a strict order, our solution is applicable in both PoOT and COT, showing that the ranking problem in COT is a special instance of a more general one in PoOT.