<commit_before>import { ApiSource, ApiPerson, ApiSubmitter } from '../models';

export class ApiComparators {
  comparePersons(a: ApiPerson, b: ApiPerson) {
    const val = a.indexName.localeCompare(b.indexName);
    if (val !== 0) {
      return val;
    }
    return a.string.localeCompare(b.string);
  }

  compareSources(a: ApiSource, b: ApiSource) {
    const val = a.title.localeCompare(b.title);
    if (val !== 0) {
      return val;
    }
    return a.string.localeCompare(b.string);
  }

  compareSubmitters(a: ApiSubmitter, b: ApiSubmitter) {
    const val = a.name.localeCompare(b.name);
    if (val !== 0) {
      return val;
    }
    return a.string.localeCompare(b.string);
  }
}
<commit_msg>reduce code duplication<commit_after>import { ApiSource, ApiPerson, ApiSubmitter } from '../models';

export class ApiComparators {
  comparePersons = (a: ApiPerson, b: ApiPerson) => {
    return this.compare(a.indexName, a.string, b.indexName, b.string);
  }

  compareSources = (a: ApiSource, b: ApiSource) => {
    return this.compare(a.title, a.string, b.title, b.string);
  }

  compareSubmitters = (a: ApiSubmitter, b: ApiSubmitter) => {
    return this.compare(a.name, a.string, b.name, b.string);
  }

  compare = (a1: string, a2: string, b1: string, b2: string) => {
    const val = a1.localeCompare(b1);
    if (val !== 0) {
      return val;
    }
    return a2.localeCompare(b2);
  }
}

{'fraction_non_alphanumeric': 0.14793741109530584, 'fraction_numerical': 0.008534850640113799, 'mean_word_length': 3.212574850299401, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '1457753', 'n_tokens_mistral': 498, 'n_tokens_neox': 507, 'n_words': 111}