QCD analysis of unpolarized and polarized Λ-baryon production in leading and next-to-leading order