<commit_before>import calf from '../support/calf';
import path from './path';
import sortDesc from './sortDesc';

function intFromString(val) {
  if (typeof val === 'string') {
    return parseInt(val.replace(/,|#/g, ''), 10);
  }
  return val;
}

function aIsNotEquipment(a) {
  return typeof a.type !== 'undefined' && a.type > 8;
}

function bIsNotEquipment(a, b) {
  return typeof a.type !== 'undefined' && b.type > 8;
}

export default function numberSort(a, b) {
  if (aIsNotEquipment(a)) {return 1;} // non equipment items
  if (bIsNotEquipment(a, b)) {return -1;}
  var valueA = path(a, calf.sortBy, 1);
  var valueB = path(b, calf.sortBy, 1);
  valueA = intFromString(valueA);
  valueB = intFromString(valueB);
  var result = valueA - valueB;
  return sortDesc(result);
}<commit_msg>use isUndefined<commit_after>import calf from '../support/calf';
import isUndefined from '../common/isUndefined';
import path from './path';
import sortDesc from './sortDesc';

function intFromString(val) {
  if (typeof val === 'string') {
    return parseInt(val.replace(/,|#/g, ''), 10);
  }
  return val;
}

function aIsNotEquipment(a) {
  return !isUndefined(a.type) && a.type > 8;
}

function bIsNotEquipment(a, b) {
  return !isUndefined(a.type) && b.type > 8;
}

export default function numberSort(a, b) {
  if (aIsNotEquipment(a)) {return 1;} // non equipment items
  if (bIsNotEquipment(a, b)) {return -1;}
  var valueA = path(a, calf.sortBy, 1);
  var valueB = path(b, calf.sortBy, 1);
  valueA = intFromString(valueA);
  valueB = intFromString(valueB);
  var result = valueA - valueB;
  return sortDesc(result);
}
{'fraction_non_alphanumeric': 0.16408668730650156, 'fraction_numerical': 0.009907120743034056, 'mean_word_length': 4.113924050632911, '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': '3607130', 'n_tokens_mistral': 607, 'n_tokens_neox': 573, 'n_words': 155}