```python
def field_of(record: dict, field: str) -> int:
    if field not in record:
        raise ValueError(f"Field '{field}' not found in record.")
    return record[field]


def sort_pairs(records: list, field: str) -> list:
    # Sorting by the specified field using a custom key function
    return sorted(records, key=lambda x: (x[field], records.index(x)))
```