Github user NarineK commented on a diff in the pull request:

    https://github.com/apache/spark/pull/8920#discussion_r40622879
  
    --- Diff: R/pkg/R/DataFrame.R ---
    @@ -1848,3 +1848,67 @@ 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
    +#' @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, TRUE, "col1","col2")
    +#' sort(df, decreasing=TRUE, "col1")
    +#' sort(df, decreasing=c(TRUE,FALSE), "col1","col2")
    +#' }
    +setMethod("sort",
    +          signature(x = "DataFrame"),
    +          function(x, decreasing=FALSE, col, ...) {
    --- End diff --
    
    Hi Felix,
    we can of course, the only thing is, that I need to embrace df$age with a 
sorting order and right now I'm doing it with string concatenation. I can try 
to get the string columns name of  df$age. That would be one option. 
    
    I'm not sure how I could concatenate the order to column object nicely. It 
might make the code look ugly. 
    I could have
    loop: 
       if (order == "asc") { asc(col)  } else {desc(col)}
    
    but this is not nice.
    Let me know what do you think .
    
    Thanks,
    Narine


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to