implemented the rank ordering