nodes: 0, module; 1, function_definition; 2, function_name:sort; 3, parameters; 4, block; 5, identifier:self; 6, identifier:key_column_names; 7, default_parameter; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, comment:# validate key_column_names; 12, if_statement; 13, comment:# use the second parameter if the sort order is not given; 14, if_statement; 15, comment:# make sure all column exists; 16, expression_statement; 17, for_statement; 18, with_statement; 19, identifier:ascending; 20, True; 21, comment:"""
          Sort current SFrame by the given columns, using the given sort order.
          Only columns that are type of str, int and float can be sorted.
  
          Parameters
          ----------
          key_column_names : str | list of str | list of (str, bool) pairs
              Names of columns to be sorted.  The result will be sorted first by
              first column, followed by second column, and so on. All columns will
              be sorted in the same order as governed by the `ascending`
              parameter. To control the sort ordering for each column
              individually, `key_column_names` must be a list of (str, bool) pairs.
              Given this case, the first value is the column name and the second
              value is a boolean indicating whether the sort order is ascending.
  
          ascending : bool, optional
              Sort all columns in the given order.
  
          Returns
          -------
          out : SFrame
              A new SFrame that is sorted according to given sort criteria
  
          See Also
          --------
          topk
  
          Examples
          --------
          Suppose 'sf' is an sframe that has three columns 'a', 'b', 'c'.
          To sort by column 'a', ascending
  
          >>> sf = turicreate.SFrame({'a':[1,3,2,1],
          ...                       'b':['a','c','b','b'],
          ...                       'c':['x','y','z','y']})
          >>> sf
          +---+---+---+
          | a | b | c |
          +---+---+---+
          | 1 | a | x |
          | 3 | c | y |
          | 2 | b | z |
          | 1 | b | y |
          +---+---+---+
          [4 rows x 3 columns]
  
          >>> sf.sort('a')
          +---+---+---+
          | a | b | c |
          +---+---+---+
          | 1 | a | x |
          | 1 | b | y |
          | 2 | b | z |
          | 3 | c | y |
          +---+---+---+
          [4 rows x 3 columns]
  
          To sort by column 'a', descending
  
          >>> sf.sort('a', ascending = False)
          +---+---+---+
          | a | b | c |
          +---+---+---+
          | 3 | c | y |
          | 2 | b | z |
          | 1 | a | x |
          | 1 | b | y |
          +---+---+---+
          [4 rows x 3 columns]
  
          To sort by column 'a' and 'b', all ascending
  
          >>> sf.sort(['a', 'b'])
          +---+---+---+
          | a | b | c |
          +---+---+---+
          | 1 | a | x |
          | 1 | b | y |
          | 2 | b | z |
          | 3 | c | y |
          +---+---+---+
          [4 rows x 3 columns]
  
          To sort by column 'a' ascending, and then by column 'c' descending
  
          >>> sf.sort([('a', True), ('c', False)])
          +---+---+---+
          | a | b | c |
          +---+---+---+
          | 1 | b | y |
          | 1 | a | x |
          | 2 | b | z |
          | 3 | c | y |
          +---+---+---+
          [4 rows x 3 columns]
          """; 22, assignment; 23, assignment; 24, parenthesized_expression; 25, block; 26, elif_clause; 27, else_clause; 28, parenthesized_expression; 29, block; 30, assignment; 31, identifier:column; 32, identifier:sort_column_names; 33, block; 34, with_clause; 35, block; 36, identifier:sort_column_names; 37, list; 38, identifier:sort_column_orders; 39, list; 40, comparison_operator:type(key_column_names) == str; 41, expression_statement; 42, parenthesized_expression; 43, block; 44, block; 45, comparison_operator:len(sort_column_orders) == 0; 46, expression_statement; 47, identifier:my_column_names; 48, call; 49, if_statement; 50, if_statement; 51, if_statement; 52, with_item; 53, return_statement; 54, call; 55, identifier:str; 56, assignment; 57, comparison_operator:type(key_column_names) == list; 58, if_statement; 59, expression_statement; 60, if_statement; 61, expression_statement; 62, if_statement; 63, raise_statement; 64, call; 65, integer:0; 66, assignment; 67, identifier:set; 68, argument_list; 69, parenthesized_expression; 70, block; 71, parenthesized_expression; 72, block; 73, parenthesized_expression; 74, block; 75, call; 76, call; 77, identifier:type; 78, argument_list; 79, identifier:sort_column_names; 80, list; 81, call; 82, identifier:list; 83, parenthesized_expression; 84, block; 85, assignment; 86, parenthesized_expression; 87, block; 88, assignment; 89, parenthesized_expression; 90, block; 91, elif_clause; 92, else_clause; 93, call; 94, identifier:len; 95, argument_list; 96, identifier:sort_column_orders; 97, list_comprehension; 98, call; 99, comparison_operator:type(column) != str; 100, raise_statement; 101, comparison_operator:column not in my_column_names; 102, raise_statement; 103, comparison_operator:self[column].dtype not in (str, int, float,datetime.datetime); 104, raise_statement; 105, identifier:cython_context; 106, argument_list; 107, identifier:SFrame; 108, argument_list; 109, identifier:key_column_names; 110, identifier:key_column_names; 111, identifier:type; 112, argument_list; 113, comparison_operator:len(key_column_names) == 0; 114, raise_statement; 115, identifier:first_param_types; 116, call; 117, comparison_operator:len(first_param_types) != 1; 118, raise_statement; 119, identifier:first_param_type; 120, call; 121, comparison_operator:first_param_type == tuple; 122, expression_statement; 123, expression_statement; 124, parenthesized_expression; 125, block; 126, block; 127, identifier:TypeError; 128, argument_list; 129, identifier:sort_column_orders; 130, identifier:ascending; 131, for_in_clause; 132, attribute; 133, argument_list; 134, call; 135, identifier:str; 136, call; 137, identifier:column; 138, identifier:my_column_names; 139, call; 140, attribute; 141, tuple; 142, call; 143, keyword_argument; 144, identifier:key_column_names; 145, call; 146, integer:0; 147, call; 148, identifier:set; 149, argument_list; 150, call; 151, integer:1; 152, call; 153, attribute; 154, argument_list; 155, identifier:first_param_type; 156, identifier:tuple; 157, assignment; 158, assignment; 159, comparison_operator:first_param_type == str; 160, expression_statement; 161, raise_statement; 162, string:"key_column_names type is not correct. Supported types are str, list of str or list of (str,bool) pair."; 163, identifier:i; 164, identifier:sort_column_names; 165, identifier:self; 166, identifier:column_names; 167, identifier:type; 168, argument_list; 169, identifier:TypeError; 170, argument_list; 171, identifier:ValueError; 172, argument_list; 173, subscript; 174, identifier:dtype; 175, identifier:str; 176, identifier:int; 177, identifier:float; 178, attribute; 179, identifier:TypeError; 180, argument_list; 181, identifier:_proxy; 182, call; 183, identifier:len; 184, argument_list; 185, identifier:ValueError; 186, argument_list; 187, list_comprehension; 188, identifier:len; 189, argument_list; 190, identifier:ValueError; 191, argument_list; 192, identifier:first_param_types; 193, identifier:pop; 194, identifier:sort_column_names; 195, list_comprehension; 196, identifier:sort_column_orders; 197, list_comprehension; 198, identifier:first_param_type; 199, identifier:str; 200, assignment; 201, call; 202, identifier:column; 203, string:"Only string parameter can be passed in as column names"; 204, binary_operator:"SFrame has no column named: '" + str(column) + "'"; 205, identifier:self; 206, identifier:column; 207, identifier:datetime; 208, identifier:datetime; 209, string:"Only columns of type (str, int, float) can be sorted"; 210, attribute; 211, argument_list; 212, identifier:key_column_names; 213, string:"Please provide at least one column to sort"; 214, call; 215, for_in_clause; 216, identifier:first_param_types; 217, string:"key_column_names element are not of the same type"; 218, subscript; 219, for_in_clause; 220, subscript; 221, for_in_clause; 222, identifier:sort_column_names; 223, identifier:key_column_names; 224, identifier:TypeError; 225, argument_list; 226, binary_operator:"SFrame has no column named: '" + str(column); 227, string:"'"; 228, attribute; 229, identifier:sort; 230, identifier:sort_column_names; 231, identifier:sort_column_orders; 232, identifier:type; 233, argument_list; 234, identifier:i; 235, identifier:key_column_names; 236, identifier:i; 237, integer:0; 238, identifier:i; 239, identifier:key_column_names; 240, identifier:i; 241, integer:1; 242, identifier:i; 243, identifier:key_column_names; 244, string:"key_column_names type is not supported"; 245, string:"SFrame has no column named: '"; 246, call; 247, identifier:self; 248, identifier:__proxy__; 249, identifier:i; 250, identifier:str; 251, argument_list; 252, identifier:column
code: def sort(self, key_column_names, ascending=True):
          """
          Sort current SFrame by the given columns, using the given sort order.
          Only columns that are type of str, int and float can be sorted.
  
          Parameters
          ----------
          key_column_names : str | list of str | list of (str, bool) pairs
              Names of columns to be sorted.  The result will be sorted first by
              first column, followed by second column, and so on. All columns will
              be sorted in the same order as governed by the `ascending`
              parameter. To control the sort ordering for each column
              individually, `key_column_names` must be a list of (str, bool) pairs.
              Given this case, the first value is the column name and the second
              value is a boolean indicating whether the sort order is ascending.
  
          ascending : bool, optional
              Sort all columns in the given order.
  
          Returns
          -------
          out : SFrame
              A new SFrame that is sorted according to given sort criteria
  
          See Also
          --------
          topk
  
          Examples
          --------
          Suppose 'sf' is an sframe that has three columns 'a', 'b', 'c'.
          To sort by column 'a', ascending
  
          >>> sf = turicreate.SFrame({'a':[1,3,2,1],
          ...                       'b':['a','c','b','b'],
          ...                       'c':['x','y','z','y']})
          >>> sf
          +---+---+---+
          | a | b | c |
          +---+---+---+
          | 1 | a | x |
          | 3 | c | y |
          | 2 | b | z |
          | 1 | b | y |
          +---+---+---+
          [4 rows x 3 columns]
  
          >>> sf.sort('a')
          +---+---+---+
          | a | b | c |
          +---+---+---+
          | 1 | a | x |
          | 1 | b | y |
          | 2 | b | z |
          | 3 | c | y |
          +---+---+---+
          [4 rows x 3 columns]
  
          To sort by column 'a', descending
  
          >>> sf.sort('a', ascending = False)
          +---+---+---+
          | a | b | c |
          +---+---+---+
          | 3 | c | y |
          | 2 | b | z |
          | 1 | a | x |
          | 1 | b | y |
          +---+---+---+
          [4 rows x 3 columns]
  
          To sort by column 'a' and 'b', all ascending
  
          >>> sf.sort(['a', 'b'])
          +---+---+---+
          | a | b | c |
          +---+---+---+
          | 1 | a | x |
          | 1 | b | y |
          | 2 | b | z |
          | 3 | c | y |
          +---+---+---+
          [4 rows x 3 columns]
  
          To sort by column 'a' ascending, and then by column 'c' descending
  
          >>> sf.sort([('a', True), ('c', False)])
          +---+---+---+
          | a | b | c |
          +---+---+---+
          | 1 | b | y |
          | 1 | a | x |
          | 2 | b | z |
          | 3 | c | y |
          +---+---+---+
          [4 rows x 3 columns]
          """
          sort_column_names = []
          sort_column_orders = []
  
          # validate key_column_names
          if (type(key_column_names) == str):
              sort_column_names = [key_column_names]
          elif (type(key_column_names) == list):
              if (len(key_column_names) == 0):
                  raise ValueError("Please provide at least one column to sort")
  
              first_param_types = set([type(i) for i in key_column_names])
              if (len(first_param_types) != 1):
                  raise ValueError("key_column_names element are not of the same type")
  
              first_param_type = first_param_types.pop()
              if (first_param_type == tuple):
                  sort_column_names = [i[0] for i in key_column_names]
                  sort_column_orders = [i[1] for i in key_column_names]
              elif(first_param_type == str):
                  sort_column_names = key_column_names
              else:
                  raise TypeError("key_column_names type is not supported")
          else:
              raise TypeError("key_column_names type is not correct. Supported types are str, list of str or list of (str,bool) pair.")
  
          # use the second parameter if the sort order is not given
          if (len(sort_column_orders) == 0):
              sort_column_orders = [ascending for i in sort_column_names]
  
          # make sure all column exists
          my_column_names = set(self.column_names())
          for column in sort_column_names:
              if (type(column) != str):
                  raise TypeError("Only string parameter can be passed in as column names")
              if (column not in my_column_names):
                  raise ValueError("SFrame has no column named: '" + str(column) + "'")
              if (self[column].dtype not in (str, int, float,datetime.datetime)):
                  raise TypeError("Only columns of type (str, int, float) can be sorted")
  
  
          with cython_context():
              return SFrame(_proxy=self.__proxy__.sort(sort_column_names, sort_column_orders))