<commit_before>package atlas;

import java.util.Comparator;

/**
 * A comparator that sorts cities based on a provided center.
 */
public class DistanceComparator implements Comparator<City> {

  private final City center;

  public DistanceComparator(City center) {
    this.center = center;
  }

  public int compare(City city1, City city2) {

    if (city1.geoNameId == city2.geoNameId) {
      return 0;
    }

    double distance1 = center.distanceTo(city1);
    double distance2 = center.distanceTo(city2);

    if (distance1 < distance2) {
      return -1;
    }
    if (distance1 > distance2) {
      return 1;
    }
    return 0;<commit_msg>Added distance comparator unit test.<commit_after>package atlas;

import java.util.Comparator;

/**
 * A comparator that sorts cities based on a provided center.
 */
public class DistanceComparator implements Comparator<City> {

  private final City center;

  public DistanceComparator(City center) {
    this.center = center;
  }

  public int compare(City city1, City city2) {

    if (city1.geoNameId > 0 && city1.geoNameId == city2.geoNameId) {
      return 0;
    }

    double distance1 = center.distanceTo(city1);
    double distance2 = center.distanceTo(city2);

    if (distance1 < distance2) {
      return -1;
    }
    if (distance1 > distance2) {
      return 1;
    }
    return 0;
{'fraction_non_alphanumeric': 0.09583952451708767, 'fraction_numerical': 0.02526002971768202, 'mean_word_length': 3.02089552238806, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4881998', 'n_tokens_mistral': 426, 'n_tokens_neox': 404, 'n_words': 119}