From lawrence.michael at gene.com  Fri Aug 26 02:55:57 2016
From: lawrence.michael at gene.com (Michael Lawrence)
Date: Thu, 25 Aug 2016 17:55:57 -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)
In-Reply-To: <CAFDcVCQS+-BiuF9KUPsbByLPCDrUPg9VfR+LOctXr=ZLcc2MGQ@mail.gmail.com>
References: <CAFDcVCQS+-BiuF9KUPsbByLPCDrUPg9VfR+LOctXr=ZLcc2MGQ@mail.gmail.com>
Message-ID: <CAOQ5NycE-iZjqqjQp5jGGcqdF7TWyNi2Op5yv+rmDoMryDGeDA@mail.gmail.com>

The radix sort should be consistent with the others, i.e., it should
behave like sort.list(), not order(). I will correct this.

On Thu, Aug 25, 2016 at 4:39 PM, Henrik Bengtsson
<henrik.bengtsson at gmail.com> wrote:
> 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)
Michael Lawrence