<think>
Okay, I need to implement the two functions field_of and sort_pairs based on the given interface. Let's start with field_of. The function is supposed to return the value of a specified field from a record dictionary. If the record doesn't have that field, it should raise a ValueError. So, first, I'll check if the field exists in the record. If not, raise the error. Otherwise, return the value.

Wait, the function is called field_of, and the parameters are record and field. The return type is int. Oh, but the field's value could be any type, but the function specifies it returns an int. Wait, the interface says the return is int. So maybe the field's value is always an integer? Or maybe that's a mistake. But according to the interface, the function is supposed to return an int. So I have to assume that the field's value is an integer. But what if the record's field is not an integer? Well, the problem says to reject a record that lacks the field, but doesn't mention checking the type. So maybe the function just returns the value as is, but the interface says it's an int. Hmm, maybe the problem expects that the field's value is an integer. So I'll proceed under that assumption.

So, for field_of: check if the field is in the record. If not, raise ValueError. Otherwise, return record[field]. But since the return is int, maybe the field's value is an integer. So the code would be straightforward.

Now, the second function: sort_pairs. It takes a list of records and a field, and returns a list of records sorted by the value of that field. If two records have the same field value, the one that comes first in the original list should stay first. So, the sort is stable, meaning that when two items are equal, their original order is preserved. So, in Python, the default sort is stable. Wait, but when you sort, if two items compare equal, their relative order is preserved. So, to achieve that, when sorting, we can use the field's value as the key, and since the default sort is stable, the original order is maintained for equal keys. Wait, but in Python, the sort is stable only when the keys are compared. So, if two items have the same key, their original order is preserved. So, for example, if we sort a list of tuples, and the keys are the same, the original order is maintained.

So, for sort_pairs, the approach is to sort the records based on the field's value. The key for sorting each record is the value of the field. Then, the sorted list is returned. But since the problem says that in case of a tie, the earlier record should come first, which is exactly the behavior of the default sort in Python. So, the code would be to sort the records using the field's value as the key, and return the sorted list.

So, for sort_pairs, the code would be: sorted_records = sorted(records, key=lambda r: field_of(r, field)). But wait, but field_of is a function that may raise an error. But in the context of sorting, all records must have the field, otherwise, the key would raise an error. But the problem says that field_of rejects a record that lacks the field. So, in the sort_pairs function, all records must have the field. So, the sort_pairs function can safely use field_of to get the key. But wait, the problem says that field_of rejects a record that lacks the field. So, in the sort_pairs function, if any record is missing the field, then field_of would raise an error.