Reputation: 44
"myview": {
"map": "function(doc) { if (doc.type == 'user') emit(doc.city,null)}",
"reduce": "_count"
},
It return city with count in value. Using group=true
How to sort this data base on highest value? Want to get most popular city first...
Upvotes: 0
Views: 242
Reputation: 48
You can use list to sort your resultset. Following function can sort anytype of a resultset on value.
"sort": "function() {
var row;
var rows=[];
while(row = getRow())
{
rows.push(row)
}
rows.sort(function(a, b)
{
return a.value - b.value;
});
rows.reverse();
send(JSON.stringify({\"rows\" : rows}))
}"
Upvotes: 1