 ;; Implement ISources for multiple directores. The pred function is
 ;; used to filter the returned files.
 
-(defrecord Directories [dirs pred]
+(defrecord Directories [dirs pred order]
   ISources
   (files [this]
-    (filter-all-descendants dirs pred)))
+    (sort-by order (filter-all-descendants dirs pred))))
 
 ;; Implement ISources and Compilable for multiple ClojureScript source
 ;; directories. The directores may contain non-ClojureScript files,

  Compilable
  (-compile [this opts]
    (let [fs (files this)]
      (reload-clj-seq fs)
      (let [d (io/file dir)]
        (flatten (map #(-compile % (assoc opts :output-file (js-file-name d %)))
                      fs))))))

       (->ClojureScriptReloadable opts sources pkgs))))

(defn dir-trigger [dir reloadable]
  (let [dir-source (->Directories [dir] (constantly true) identity)]
    (->DirDependency dir-source [reloadable])))

;; Examples
