<commit_before>import naturalSort from 'javascript-natural-sort';
import objectPropertyNaturalSort from 'object-property-natural-sort';

export default {

  alphabetical(data, key) {
    if (key) {
      data.sort((datum1, datum2) => {
        const item1 = datum1[key].toLowerCase();
        const item2 = datum2[key].toLowerCase();
        const expr1 = -1;
        const expr2 = item1 > item2 ? 1 : 0;
        return item1 < item2 ? expr1 : expr2;
      });
    } else {
      data.sort();
    }
    return data;
  },

  natural(data, key) {
    if (key) {
      return data.sort(objectPropertyNaturalSort(key));
    }
    return data.sort(naturalSort);
  },

  numericAscending(data, key) {
    data.sort((datum1, datum2) => {
      if (key) {
        return datum1[key] - datum2[key];
      }
      return datum1 - datum2;
    });
    return data;
  },

  numericDescending(data, key) {
    data.sort((datum1, datum2) => {
      if (key) {
        return datum2[key] - datum1[key];
      }
      return datum2 - datum1;
    });
    return data;
  },

};<commit_msg>improve syntax in SortUtil<commit_after>import naturalSort from 'javascript-natural-sort';
import objectPropertyNaturalSort from 'object-property-natural-sort';

export default {

  alphabetical(data, key) {
    return key ?
      data.sort((datum1, datum2) => {
        const item1 = datum1[key].toLowerCase();
        const item2 = datum2[key].toLowerCase();
        const expr1 = -1;
        const expr2 = item1 > item2 ? 1 : 0;
        return item1 < item2 ? expr1 : expr2;
      }) :
      data.sort();
  },

  natural(data, key) {
    return key ?
      data.sort(objectPropertyNaturalSort(key)) :
      data.sort(naturalSort);
  },

  numericAscending(data, key) {
    return data.sort((datum1, datum2) => key ?
      datum1[key] - datum2[key] :
      datum1 - datum2
    );
  },

  numericDescending(data, key) {
    return data.sort((datum1, datum2) => key ?
      datum2[key] - datum1[key] :
      datum2 - datum1
    );
  },

};
{'fraction_non_alphanumeric': 0.13887506222000995, 'fraction_numerical': 0.02887008461921354, 'mean_word_length': 2.4125636672325976, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '477398', 'n_tokens_mistral': 715, 'n_tokens_neox': 694, 'n_words': 142}