                                 :status    "ok"}
             :progress-running? false
             :player            {}
-            :evolution-number  0}))
+            :evolution-number  0
+            :sort-asc              true}))
 
 (declare get-pokemon-by-id)
 (declare evolution-sum)
-
-(defonce sort-direction-asc (atom true))
+(declare reconciler)
+
 ;;;; React compatibility
 (defonce counter (atom 0))
 

(defn sort-pokemon!
  "Sort complete list of pokemon by given key."
  [key]
  (om/transact! reconciler `[(sort/pokemon {:key ~key})]))

(defn update-player!
  "Update the playerdata."

  [{:keys [state]} _ {:keys [player]}]
  {:action (fn [] (swap! state update-in [:player] (fn [] player)))})

(defmethod mutate 'sort/pokemon
  [{:keys [state]} _ {:keys [key]}]
  {:action (fn [] (swap! state update-in [:pokemon] (fn [] (cond-> (sort-by (juxt key :individual_percentage :cp) (:pokemon @state))
                                                                  (:sort-asc @state) reverse))))})

(defmethod mutate 'sort/toggle-asc
  [{:keys [state]} _ {:keys []}]
  {:action (fn [] (swap! state update-in [:sort-asc] not))})

(defmethod mutate 'change/view
  [{:keys [state]} _ {:keys [view]}]
