nodes: 0, module; 1, function_definition; 2, function_name:nullity_sort; 3, parameters; 4, block; 5, identifier:df; 6, default_parameter; 7, expression_statement; 8, if_statement; 9, identifier:sort; 10, None; 11, comment:"""
      Sorts a DataFrame according to its nullity, in either ascending or descending order.
  
      :param df: The DataFrame object being sorted.
      :param sort: The sorting method: either "ascending", "descending", or None (default).
      :return: The nullity-sorted DataFrame.
      """; 12, comparison_operator:sort == 'ascending'; 13, block; 14, elif_clause; 15, else_clause; 16, identifier:sort; 17, string; 18, return_statement; 19, comparison_operator:sort == 'descending'; 20, block; 21, block; 22, string_content:ascending; 23, subscript; 24, identifier:sort; 25, string; 26, return_statement; 27, return_statement; 28, attribute; 29, call; 30, slice; 31, string_content:descending; 32, subscript; 33, identifier:df; 34, identifier:df; 35, identifier:iloc; 36, attribute; 37, argument_list; 38, attribute; 39, call; 40, slice; 41, identifier:np; 42, identifier:argsort; 43, attribute; 44, identifier:df; 45, identifier:iloc; 46, attribute; 47, argument_list; 48, call; 49, identifier:values; 50, identifier:np; 51, identifier:flipud; 52, call; 53, attribute; 54, argument_list; 55, attribute; 56, argument_list; 57, identifier:df; 58, identifier:count; 59, keyword_argument; 60, identifier:np; 61, identifier:argsort; 62, attribute; 63, identifier:axis; 64, string; 65, call; 66, identifier:values; 67, string_content:columns; 68, attribute; 69, argument_list; 70, identifier:df; 71, identifier:count; 72, keyword_argument; 73, identifier:axis; 74, string; 75, string_content:columns
code: def nullity_sort(df, sort=None):
      """
      Sorts a DataFrame according to its nullity, in either ascending or descending order.
  
      :param df: The DataFrame object being sorted.
      :param sort: The sorting method: either "ascending", "descending", or None (default).
      :return: The nullity-sorted DataFrame.
      """
      if sort == 'ascending':
          return df.iloc[np.argsort(df.count(axis='columns').values), :]
      elif sort == 'descending':
          return df.iloc[np.flipud(np.argsort(df.count(axis='columns').values)), :]
      else:
          return df