Unimodality of ranks and a proof of Stanton's conjecture