Skip to content
Prev 59466 / 63433 Next

Does type raw really have no ordering?

On 08/02/2021 13:25, Hugh Parsonage wrote:
Please re-read the help for which.min: as it says you computed on an 
internal coercion to double.  Doubles do have an ordering.

Like factors, raw vectors have numeric codes, but that does not imply 
that the ordering of the numeric codes is relevant to the original 
object.  And reading the help for comparisons would have informed you

      Raw vectors should not really be considered to have an order, but
      the numeric order of the byte representation is used.

One use case for a raw vector is to store bytes in an unspecified 8-bit 
encoding.  What ordering would be relevant depends on the encoding - 
this is even true for the ASCII subset - some people sort AaBb some 
AB...ab and some locales even sort aAbB (although I have never seen that 
recommended for human usage).