Skip to content

sorting in CharacterVector is not equal to sorting in R #251

Description

@emiliotorres

Lexicographic order in CharacterVector differs from the result obtained in R. See example.
Is this result the expected behaviour?
Thank you!

#include <Rcpp.h>
using namespace Rcpp ;

// [[Rcpp::export]]
CharacterVector sortcpp(CharacterVector x) {
  x.sort();
  return x;
  }

/*** R
     x <-c("B", "b", "c","A","a")
     sort(x)    ## "a" "A" "b" "B" "c"
     sortcpp(x) ## "A" "B" "a" "b" "c"
*/

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions