```ts
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];
}

export function sortPairs(records: Record<string, number>[], field: string): Record<string, number>[] {
  return records.sort((a, b) => {
    const valA = a[field];
    const valB = b[field];

    if (valA === valB) {
      return 0;
    }

    if (isNaN(valA) && !isNaN(valB)) {
      return -1; // Nullish coalescing for NaN
    }

    return valA < valB ? -1 : 1;
  });
}
```