def recovery_data_key_function(item):
    """
    Convert item in `RecoveryDialog.data` to tuple so that it can be sorted.

    Sorting the tuples returned by this function will sort first by name of
    the original file, then by name of the autosave file. All items without an
    original file name will be at the end.
    """
    orig_dict, autosave_dict = item
    if orig_dict:
        return (0, orig_dict['name'], autosave_dict['name'])
    else:
        return (1, 0, autosave_dict['name'])