function sort(a, b, hashCode) {
  // Short-circuit comparison if a and b are strictly equal
  // This is absolutely necessary for indexed objects that
  // don't have the idAttribute field
  if (a === b) {
    return 0;
  }

  if (hashCode) {
    a = hashCode(a);
    b = hashCode(b);
  }

  if (a === null && b === null || a === undefined && b === undefined) {
    return -1;
  }

  if (a === null || a === undefined) {
    return -1;
  }

  if (b === null || b === undefined) {
    return 1;
  }

  if (a < b) {
    return -1;
  }

  if (a > b) {
    return 1;
  }

  return 0;
}
Create a subclass of this Record:
@example <caption>Record.extend</caption>
const JSData = require('js-data');
const { Record } = JSData;
console.log('Using JSData v' + JSData.version.full);

// Extend the class using ES2015 class syntax.
class CustomRecordClass extends Record {
  foo () { return 'bar'; }
  static beep () { return 'boop'; }
}
const customRecord = new CustomRecordClass();
console.log(customRecord.foo());
console.log(CustomRecordClass.beep());

// Extend the class using alternate method.
const OtherRecordClass = Record.extend({
  foo () { return 'bar'; }
}, {
  beep () { return 'boop'; }
});
const otherRecord = new OtherRecordClass();
console.log(otherRecord.foo());
console.log(OtherRecordClass.beep());

// Extend the class, providing a custom constructor.
function AnotherRecordClass () {
  Record.call(this);
  this.created_at = new Date().getTime();
}
Record.extend({
  constructor: AnotherRecordClass,
  foo () { return 'bar'; }
}, {
  beep () { return 'boop'; }
});
const anotherRecord = new AnotherRecordClass();
console.log(anotherRecord.created_at);
console.log(anotherRecord.foo());
console.log(AnotherRecordClass.beep());

@method Record.extend
@param {object} [props={}] Properties to add to the prototype of the
subclass.
@param {object} [props.constructor] Provide a custom constructor function
to be used as the subclass itself.
@param {object} [classProps={}] Static properties to add to the subclass.
@returns {Constructor} Subclass of this Record class.
@since 3.0.0