nearly completes the rankall.R function for c2a3