<commit_before>define([
  "Backbone"
], function(Backbone) {
  var DEFAULT_ATTR = "id";
  function comparator(a, b) {
    // Assuming that the sortKey values can be compared with '>' and '<'
    a = a.get(this.sortKey);
    b = b.get(this.sortKey);
    return this.sortReverse
            ? b < a ? 1 : b > a ? -1 : 0 // reversed
            : a < b ? 1 : a > b ? -1 : 0; // regular
  };
  var SortableCollection = Backbone.Collection.extend({
    comparator: comparator,
    setComparator: function(attribute) {
      attribute = attribute || DEFAULT_ATTR;
      this.sortReverse = attribute.substr(0, 1) === "-";
      this.sortKey = this.sortReverse ? attribute.substr(1) : attribute;

    }
  });

  return SortableCollection;
});
<commit_msg>Moving comparator function into setComparator func<commit_after>define([
  "Backbone"
], function(Backbone) {
  var DEFAULT_ATTR = "id";
  var SortableCollection = Backbone.Collection.extend({
    setComparator: function(attribute) {
      attribute = attribute || DEFAULT_ATTR;
      this.sortReverse = attribute.substr(0, 1) === "-";
      this.sortKey = this.sortReverse ? attribute.substr(1) : attribute;
      this.comparator = function(a, b) {
        // Assuming that the sortKey values
        // can be compared with '>' and '<'
        a = a.get(this.sortKey);
        b = b.get(this.sortKey);
        return this.sortReverse
                ? b < a ? 1 : b > a ? -1 : 0 // reversed
                : a < b ? 1 : a > b ? -1 : 0; // regular
      };
    }
  });

  return SortableCollection;
});

{'fraction_non_alphanumeric': 0.14175257731958762, 'fraction_numerical': 0.011597938144329897, 'mean_word_length': 2.405701754385965, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7147846', 'n_tokens_mistral': 508, 'n_tokens_neox': 483, 'n_words': 123}