      (map midi->str newnotes))))
 
 (defn transform-dict [dict trans]
-  (let [kws (keys dict)
-        oldvals (vals dict)
+  (let [sorted (sort-by key compare-keywords dict)
+        kws (keys sorted)
+        oldvals (vals sorted)
         newvals (trans oldvals)
         pairs (map #(vector %1 %2) kws newvals)]
-    (into {} pairs)))    
+    (into {} pairs)))
     
 (defn transform-necklace [trans id typekw]
   (let [panel (id->panel id)

  (let [[w h] (get-panel-size)
        rhy-hours (get (get @melody-map id) :beats)
        rhy-angle (/ (* 2 (Math/PI)) rhy-hours)
        radius (* w 0.3)
        [xc yc] [(/ w 2) (* h 0.6)]
        [wb hb] [50 20]]
    (map (fn [n]
           (let [angle (+ (/ Math/PI -2) (* n rhy-angle))

  (let [[w h] (get-panel-size)
        mel-hours (get (get @melody-map id) :pitches)
        mel-angle (/ (* 2 (Math/PI)) mel-hours)
        radius (* w 0.4)
        [xc yc] [(/ w 2) (* h 0.25)]
        [wb hb] [50 20]]
    (map (fn [n]
           (let [angle (+ (/ Math/PI -2) (* n mel-angle))
