Reputation: 3118
How I can get documents ordered by key1 (ascending) and key2 (descending) in a view?
Upvotes: 3
Views: 174
Reputation: 6237
Very interesting question, the only answer I can think of is to write a map function that emits as key an array containing the asc key and the "opposite" of the desc key:
emit([doc.ascKey, opposite(doc.descKey)], doc);
The opposite function should iterate characters of the desc key to calculate the "alphabetical opposite" of them; for simplicity in ASCII it would be something like this pseudo-code snippet:
var oppositeStr = "";
for (char in str) {
oppositeStr += chr(255 - char);
}
My solution is just speculative, but may also work! Maybe someone has a better idea?
Upvotes: 1