turicreate.SFrame.sort¶

SFrame.
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
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]