couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Davis <>
Subject Re: How to specify different sort order for the elements of a compound map key?
Date Wed, 05 Sep 2012 05:42:25 GMT
Unfortunately no. There was a patch to define a sort order for array
keys but it was never committed to master. Its not a terribly
difficult patch but there hasn't ever been much of a call for such a
thing (AFAIK you're the second ever) and it has some awkward edge
cases. Perhaps a revisit would be kosher.

For background the original patch was a design doc member of [true,
false, true, true] (["asc", "desc", "asc", "asc"] would be
equivalently easy). We'll need to look into making this a per-view
option as well as including it in the design doc signature. We'd also
need to account for the newer raw collation option as well and define
that. Or perhaps make this a new collation option.

If anyone wants to dig into this I can point to the major code areas
and general points of concern but I don't have time to dig in

On Tue, Sep 4, 2012 at 11:16 PM, Pulkit Singhal <> wrote:
> I have a map with a compound key which naturally sorts in an ascending
> order as:
> [No, 2011]
> [No, 2012]
> [Yes, 2011]
> [Yes, 2012]
> But I want it to sort as:
> [No, 2012]
> [No, 2011]
> [Yes, 2012]
> [Yes, 2011]
> Which means the first element in the key No/Yes should be sorted in an
> ascending order, whereas the timestamp should be sorted in a descending
> order.
> Is there a way to do this in a query? Or do I have to come up with some
> hack in my mapping function?

View raw message