              tx))
          txes)))
 
+
+
 (defn copy-transactions [db doc new-doc & {:keys [sleep-ms]
                                            :or {sleep-ms 1000}}]
   (let [conn (pcd/conn)
         tx-datas (->> (get-document-transactions db doc)
-                   (sort-by :db/txInstant)
                    (map (fn [t]
-                          (->> (tx-data t)
+                          (->> (:tx-data t)
                             (remove #(= (:e %) (:db/id t)))
                             (map #(if (= (:v %) (:db/id doc))
                                     (assoc % :v (:db/id new-doc))

    (map ->datom)
    set))

(defn replace-frontend-ids [db doc-id txes]
  (let [a (d/entid db :frontend/id)]
    (map (fn [tx]

            [pc.datomic.schema :as schema]
            [pc.datomic.web-peer :as web-peer])
  (:import java.util.UUID))

(defn- ->datom
  [[e a v tx added]]
