def splitA(fitnesses, obj):
 median_ = median(fitnesses, itemgetter(obj))
 (best_a, worst_a) = ([], [])
 (best_b, worst_b) = ([], [])
 for fit in fitnesses:
  if (fit[obj] > median_):
   best_a.append(fit)
   best_b.append(fit)
  elif (fit[obj] < median_):
   worst_a.append(fit)
   worst_b.append(fit)
  else:
   best_a.append(fit)
   worst_b.append(fit)
 balance_a = abs((len(best_a) - len(worst_a)))
 balance_b = abs((len(best_b) - len(worst_b)))
 if (balance_a <= balance_b):
  return (best_a, worst_a)
 else:
  return (best_b, worst_b)

def splitA ( fitnesses , obj ) : median_ = median ( fitnesses , itemgetter ( obj ) ) ( best_a , worst_a ) = ( [ ] , [ ] ) ( best_b , worst_b ) = ( [ ] , [ ] ) for fit in fitnesses : if ( fit [ obj ] > median_ ) : best_a . append ( fit ) best_b . append ( fit ) elif ( fit [ obj ] < median_ ) : worst_a . append ( fit ) worst_b . append ( fit ) else : best_a . append ( fit ) worst_b . append ( fit ) balance_a = abs ( ( len ( best_a ) - len ( worst_a ) ) ) balance_b = abs ( ( len ( best_b ) - len ( worst_b ) ) ) if ( balance_a <= balance_b ) : return ( best_a , worst_a ) else : return ( best_b , worst_b )
partition the set of fitnesses in two according to the median of the objective index *obj* .