             {:$divide
              [dollar interval]}}]}
          :count {:$sum 1}}}
-       {:$sort {"_id" -1}}]
-      dollar
+       {:$sort {"_id" 1}}]
+      {:$map
+       {:input dollar
+        :as "index"
+        :in
+        {(keyword outer) "$$index._id"
+         :count "$$index.count"}}}
       dollar]]))
 
 (defn render-aggregate

       {:input dollar
        :as "index"
        :in
        {:k "$$index._id"
         :v "$$index.count"}}}
      {:$arrayToObject dollar}]]))

(defn render-percentile
  [outer percentiles]

(defn group-count
  [path]
  [{:$group {:_id (dollar path) :count {:$sum 1}}}
   {:$project {(name path) "$_id" :count "$count"}}])

(defn unwind
  [label]
