From henrik.bengtsson at gmail.com  Fri Aug 26 01:39:35 2016
From: henrik.bengtsson at gmail.com (Henrik Bengtsson)
Date: Thu, 25 Aug 2016 16:39:35 -0700
Subject: [Rd] sort.int(c(2, NA, 4), index.return=TRUE, na.last=NA,
 method)$ix differ for method="radix" and "shell"/"quick" (+ new
 default in R-devel)
Message-ID: <CAFDcVCQS+-BiuF9KUPsbByLPCDrUPg9VfR+LOctXr=ZLcc2MGQ@mail.gmail.com>

Does sort.int(c(2,NA,4), index.return=TRUE, na.last=NA,
method="radix")$ix give the intended result, because I get:

> sort.int(c(2,NA,4), index.return=TRUE, na.last=NA, method="radix")
$x
[1] 2 4

$ix
[1] 1 3

With method="shell" and method="quick" in R devel, I get:

> sort.int(c(2,NA,4), index.return=TRUE, na.last=NA, method="shell")
$x
[1] 2 4

$ix
[1] 1 2

> sort.int(c(2,NA,4), index.return=TRUE, na.last=NA, method="quick")
$x
[1] 2 4

$ix
[1] 1 2

Is this correct?  Should we expect sort.int(c(2,NA,4),
index.return=TRUE, na.last=NA)$ix to be the same regardless of
'method'?



BACKGROUND:

I recently discovered that some of my package tests on functions using
sort(x, index.return=TRUE) where double 'x' may contain missing values
fails.  I traced it down to the update in R-devel (2016-08-2? r70856)
where method="radix" became the new default;

svn log -r 70856
------------------------------------------------------------------------
r70856 | lawrence | 2016-06-29 16:59:30 -0700 (Wed, 29 Jun 2016) | 3 lines

radix is default sort algorithm for doubles (no more rounding),
grouping() puts NAs last.

which I think is why we in R devel now observe:

> sort(c(2,NA,4), index.return=TRUE)
$x
[1] 2 4

$ix
[1] 1 3

whereas prior to this we saw:

> sort(c(2,NA,4), index.return=TRUE)
$x
[1] 2 4

$ix
[1] 1 2

/Henrik



[Rd] sort.int(c(2, NA, 4), index.return=TRUE, na.last=NA, method)$ix differ for method="radix" and "shell"/"quick" (+ new default in R-devel)
Henrik Bengtsson