<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def save_as_json(total: list, name='data.json', sort_by: str = None, no_duplicate=False, order='asc'):
 """Save what you crawled as a json file. Args: total (list):
 Total of data you crawled. name (str, optional):
 Defaults to 'data.json'. The name of the file. sort_by (str, optional):
 Defaults to None. Sort items by a specific key. no_duplicate (bool, optional):
 Defaults to False. If True, it will remove duplicated data. order (str, optional):
 Defaults to 'asc'. The opposite option is 'desc'. """

    if sort_by:
        reverse = order == 'desc'
        total = sorted(total, key=itemgetter(sort_by), reverse=reverse)
    if no_duplicate:
        total = [key for key, _ in groupby(total)]
    data = json.dumps(total, ensure_ascii=False)
    Path(name).write_text(data, encoding='utf-8')