[scala] Change CaseClassSerializer/Comparator to not use For-Loop