Skip to content
Prev 43403 / 63424 Next

Expected behaviour of is.unsorted?

On 12-05-23 4:37 AM, Matthew Dowle wrote:
If you look at the source, you will see that the basic test for classed 
objects is

all(x[-1L] >= x[-length(x)])

(in the function base:::.gtn).

This comparison doesn't really makes sense for dataframes, but it does 
seem to be backwards:  that tests that x[2] >= x[1], x[3] >= x[2], etc., 
returning TRUE if all comparisons are TRUE:  but that sounds like it 
should be is.sorted(), not is.unsorted().  Or is it my brain that is 
backwards?

Duncan Murdoch