mongo集团订单

i try to run such code

$collection->group(array('goods_id'=>1, 'server_id'=>1), array('count' => 0, 'ip'=>'', 'date'=>''), 'function (obj, prev) { prev.count++; prev.ip=obj.user_ip; prev.date=obj.time_download }')->sort(array('count'=>1));

without sort works, with sort not work any ideas?

MongoDB does not yet support grouping and ordering in a single query. Until it can, you can do two things:

  1. Sort the result of the group query in your code ('client side')
  2. Run a MapReduce and run a query, with sort(), on the collection that the MapReduce outputs