nodes: 0, module; 1, function_definition; 2, function_name:save_as_json; 3, parameters; 4, block; 5, typed_parameter; 6, default_parameter; 7, typed_default_parameter; 8, default_parameter; 9, default_parameter; 10, expression_statement; 11, if_statement; 12, if_statement; 13, expression_statement; 14, expression_statement; 15, identifier:total; 16, type; 17, identifier:name; 18, string; 19, identifier:sort_by; 20, type; 21, None; 22, identifier:no_duplicate; 23, False; 24, identifier:order; 25, string; 26, comment:"""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'.
      """; 27, identifier:sort_by; 28, block; 29, identifier:no_duplicate; 30, block; 31, assignment; 32, call; 33, identifier:list; 34, string_content:data.json; 35, identifier:str; 36, string_content:asc; 37, expression_statement; 38, expression_statement; 39, expression_statement; 40, identifier:data; 41, call; 42, attribute; 43, argument_list; 44, assignment; 45, assignment; 46, assignment; 47, attribute; 48, argument_list; 49, call; 50, identifier:write_text; 51, identifier:data; 52, keyword_argument; 53, identifier:reverse; 54, comparison_operator:order == 'desc'; 55, identifier:total; 56, call; 57, identifier:total; 58, list_comprehension; 59, identifier:json; 60, identifier:dumps; 61, identifier:total; 62, keyword_argument; 63, identifier:Path; 64, argument_list; 65, identifier:encoding; 66, string; 67, identifier:order; 68, string; 69, identifier:sorted; 70, argument_list; 71, identifier:key; 72, for_in_clause; 73, identifier:ensure_ascii; 74, False; 75, identifier:name; 76, string_content:utf-8; 77, string_content:desc; 78, identifier:total; 79, keyword_argument; 80, keyword_argument; 81, pattern_list; 82, call; 83, identifier:key; 84, call; 85, identifier:reverse; 86, identifier:reverse; 87, identifier:key; 88, identifier:_; 89, identifier:groupby; 90, argument_list; 91, identifier:itemgetter; 92, argument_list; 93, identifier:total; 94, identifier:sort_by
code: 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')