fixed sorting algorithm before breading and mutation, also fixe the way to get the distance