Github user shivaram commented on a diff in the pull request:
https://github.com/apache/spark/pull/8920#discussion_r40991002
--- Diff: R/pkg/R/DataFrame.R ---
@@ -1848,3 +1848,57 @@ setMethod("crosstab",
sct <- callJMethod(statFunctions, "crosstab", col1, col2)
collect(dataFrame(sct))
})
+
+#' Sort
+#'
+#' Sort a DataFrame by the specified column(s).
+#'
+#' @param x A DataFrame to be sorted.
+#' @param by A character column indicating the field to sort on.
+#' if the column names are specified as Column object arrange
function
+#' can be used instead
+#' @param decreasing Orderings for each sorting column
+#' @param ... Additional sorting fields
+#' @return A DataFrame where elements are sorted by input sorting columns.
+#' @rdname sort
+#' @name sort
+#' @aliases orderby
+#' @export
+#' @examples
+#'\dontrun{
+#' sc <- sparkR.init()
+#' sqlContext <- sparkRSQL.init(sc)
+#' path <- "path/to/file.json"
+#' df <- jsonFile(sqlContext, path)
+#' sort(df, col="col1")
+#' sort(df, decreasing=FALSE, "col2")
+#' sort(df, decreasing=TRUE, "col1")
+#' sort(df, c(TRUE,FALSE), "col1","col2")
+#' }
+setMethod("sort",
+ signature(x = "DataFrame"),
+ function(x, decreasing=FALSE, col, ...) {
+
+ # all sorting columns
+ by <- c(col, ...)
+ if (length(decreasing) == 1){
+ # in case only 1 boolean argument - decreasing value is
specified,
+ # it will be used for all columns
+ decreasing <- rep(decreasing,length(by))
--- End diff --
space after `,`
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]