def rankedFitness(R):
 res = zeros_like(R)
 l = list(zip(R, list(range(len(R)))))
 l.sort()
 for (i, (_, j)) in enumerate(l):
  res[j] = i
 return res

def rankedFitness ( R ) : res = zeros_like ( R ) l = list ( zip ( R , list ( range ( len ( R ) ) ) ) ) l . sort ( ) for ( i , ( _ , j ) ) in enumerate ( l ) : res [ j ] = i return res
produce a linear ranking of the fitnesses in r .