Write a function to merge two large datasets efficiently.
Each dataset is sorted by a unique integer key and contains records represented as [key, value]. Return one sorted dataset containing every key, using the record from second when both datasets contain the same key. The input datasets must not be modified.
Function contract: merge_datasets(first, second) receives two lists of records and returns a new list of records. Values may be strings, numbers, booleans, or null.
def merge_datasets(first, second):