In reply to Ian Wakeling.

Thanks for the tip about missing values! I write the comparison operators in my LOC calls so that the code is easier to read, but the correct handling of missing values is a nice bonus. These fast O(n) operations won't make any difference in the performance of an O(n^2) or O(n^3) algorithm.