Critical temperature
Higher is the critical temperature of a gas, easier is its liquefaction. This means that the intermolecular forces of attraction between the molecules of a gas are directly proportional to its critical temperature.
Hence, Ammonia will liquify first because its critical temperature will be reached first. Liquefaction of CO2 will require more cooling.