The function provided to R.sortBy causes a simple equality check to be performed on keys (a < b). The problem I discovered is that arrays are caught in the if (typeof k === 'object' && k !== null) check. This results in the comparison being done as a string instead of an array, which produces incorrect ordering.
It looks like Couch view collation applies key ordering implicitly (should not only be done if user provides starkey, endkey, descending, etc.). Therefore, it seems best to use keyCompare here in every case. This fixes the issue I was seeing with arrays, and presumably will fix any possible issues with other key type comparisons.
The function provided to R.sortBy causes a simple equality check to be performed on keys (a < b). The problem I discovered is that arrays are caught in the
if (typeof k === 'object' && k !== null)
check. This results in the comparison being done as a string instead of an array, which produces incorrect ordering.It looks like Couch view collation applies key ordering implicitly (should not only be done if user provides starkey, endkey, descending, etc.). Therefore, it seems best to use keyCompare here in every case. This fixes the issue I was seeing with arrays, and presumably will fix any possible issues with other key type comparisons.
I would appreciate any feedback!