Skip to content

sort() and attributes

1 message · Brian Ripley

#
After the discussion a while back about how sort inconsistently handles 
attributes such as dim's, I have taken a closer look and found yet more 
anomalies.

That suggested trying out the principle that sort() should preserve only 
names (and sort those).  Now, sort(partial=) was preserving names and NOT 
sorting them, and since it was included for efficiency I decided it should 
just drop names.

One consequence of this is that sort() would drop S3 classes (which is 
necessary for e.g. time-series-like classes).

I have tested this out over CRAN packages and it is currently live in 
R-devel.  The only thing I can see it breaks is lattice (sorry Deepayan, 
please take a look at the changes made to axis.Date whose code you 
borrowed).

Given that this is close to what S does and sort() was not documented to 
preserve attributes, I was not expecting much impact from this change. 
Since it seems to have minimal impact this seems the best way forward, but 
I am open to counter-proposals.