```ts
/**
 * Returns the value associated with the specified field in a record,
 * or rejects the promise if the field is missing.
 */
export function fieldOf(record: Record<string, number>, field: string): number {
  if (!record.hasOwnProperty(field)) {
    throw new Error(`Record does not have field '${field}'`);
  }
  return record[field];
}

/**
 * Sorts an array of records by a specified field. Breaks ties by
 * leaving the earlier record earlier.
 */
export function sortPairs(records: Record<string, number>[], field: string): Record<string, number>[] {
  if (records.length === 0) {
    throw new Error('Cannot sort empty array');
  }

  return records.sort((a, b) => {
    const aValue = a[field];
    const bValue = b[field];

    // Handle NaN values
    if (isNaN(aValue) && isNaN(bValue)) {
      return 0; // LeaveNaNs in the same order
    } else if (isNaN(aValue)) {
      return -1;
    } else if (isNaN(bValue)) {
      return 1;
    }

    // Compare numbers as numbers
    if (typeof aValue === 'number' && typeof bValue === 'number') {
      return aValue - bValue;
    }

    // Compare strings as strings (ensures consistent order for different types)
    return aValue.localeCompare(bValue);
  });
}
```