Skip to content

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

@emiliotorres

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"
*/

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