<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _write_json(file, contents):
 """Write a dict to a JSON file."""

    with open(file, 'w') as f:
        return json.dump(contents, f, indent=2, sort_keys=True)