nodes: 0, module; 1, function_definition; 2, function_name:sort; 3, parameters; 4, block; 5, identifier:self; 6, identifier:field; 7, default_parameter; 8, expression_statement; 9, if_statement; 10, if_statement; 11, expression_statement; 12, identifier:direction; 13, string:"asc"; 14, comment:"""
          Adds sort criteria.
          """; 15, not_operator; 16, block; 17, comparison_operator:direction not in ["asc", "desc"]; 18, block; 19, call; 20, call; 21, raise_statement; 22, identifier:direction; 23, list; 24, raise_statement; 25, attribute; 26, argument_list; 27, identifier:isinstance; 28, argument_list; 29, call; 30, string:"asc"; 31, string:"desc"; 32, call; 33, attribute; 34, identifier:append; 35, dictionary; 36, identifier:field; 37, identifier:basestring; 38, identifier:ValueError; 39, argument_list; 40, identifier:ValueError; 41, argument_list; 42, identifier:self; 43, identifier:sorts; 44, pair; 45, string:"Field should be a string"; 46, string:"Sort direction should be `asc` or `desc`"; 47, identifier:field; 48, identifier:direction
code: def sort(self, field, direction="asc"):
          """
          Adds sort criteria.
          """
          if not isinstance(field, basestring):
              raise ValueError("Field should be a string")
          if direction not in ["asc", "desc"]:
              raise ValueError("Sort direction should be `asc` or `desc`")
  
          self.sorts.append({field: direction})