2016-07-15 41 views

回答

2

我認爲他們是同義詞:

看看this

def sort(self, *cols, **kwargs): 
    """Returns a new :class:`DataFrame` sorted by the specified column(s). 
    :param cols: list of :class:`Column` or column names to sort by. 
    :param ascending: boolean or list of boolean (default True). 
     Sort ascending vs. descending. Specify list for multiple sort orders. 
     If a list is specified, length of the list must equal length of the `cols`. 
    >>> df.sort(df.age.desc()).collect() 
    [Row(age=5, name=u'Bob'), Row(age=2, name=u'Alice')] 
    >>> df.sort("age", ascending=False).collect() 
    [Row(age=5, name=u'Bob'), Row(age=2, name=u'Alice')] 
    >>> df.orderBy(df.age.desc()).collect() 
    [Row(age=5, name=u'Bob'), Row(age=2, name=u'Alice')] 
    >>> from pyspark.sql.functions import * 
    >>> df.sort(asc("age")).collect() 
    [Row(age=2, name=u'Alice'), Row(age=5, name=u'Bob')] 
    >>> df.orderBy(desc("age"), "name").collect() 
    [Row(age=5, name=u'Bob'), Row(age=2, name=u'Alice')] 
    >>> df.orderBy(["age", "name"], ascending=[0, 1]).collect() 
    [Row(age=5, name=u'Bob'), Row(age=2, name=u'Alice')] 
    """ 
    jdf = self._jdf.sort(self._sort_cols(cols, kwargs)) 
    return DataFrame(jdf, self.sql_ctx) 

orderBy = sort 
相關問題