The issue here is rather that sort.list() does not implement complex vectors: order() uses sort.list() for speed if it has a single argument.
How sort() and order() collate complex numbers seems to be undocumented in R. I was taught that they were unsorted, and there are several possible sort orders. It seems the collation is as a (real, imaginary) pair. This will be fixed for R 2.4.0: please consider a suitable donation to the R Foundation for the reduction in your annoyance. On Wed, 28 Jun 2006, [EMAIL PROTECTED] wrote: > Full_Name: Murray Smith > Version: 2.2.1 How did you manage to miss all the injunctions not to report on obselete versions of R? > OS: Windows XP > Submission from: (NULL) (202.36.29.1) > > > order() will not allow a complex vector for its first argument. This contrasts > with sort() which will happily sort a complex vector. > > While this may not be regarded as a bug by some, it is annoying for anyone who > makes frequent use of complex numbers. > > The problem occured in the Windows version 2.2.1 of R, but it has been present > in earlier versions. >> version > _ > platform i386-pc-mingw32 > arch i386 > os mingw32 > system i386, mingw32 > status > major 2 > minor 2.1 > year 2005 > month 12 > day 20 > svn rev 36812 > language R > > An example demonstrating the problem: > x <- rep(2:1, c(2, 2)) + 1i*c(4, 1, 2, 3) >> x > [1] 2+4i 2+1i 1+2i 1+3i >> order(x) > Error in order(x) : unimplemented type 'complex' in 'orderVector1' > > However sort() works with complex arguments >> sort(x) > [1] 1+2i 1+3i 2+1i 2+4i > > The problem can be worked around either by >> order(Re(x), Im(x)) > [1] 3 4 2 1 > > or, because order() allows subsequent arguments to be complex, by using a > constant vector for the first argument >> order(numeric(length(x)), x) > [1] 3 4 2 1 > > ______________________________________________ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel > > -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595 ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel