+;;;;
+;;;; LilyPond is free software: you can redistribute it and/or modify
+;;;; it under the terms of the GNU General Public License as published by
+;;;; the Free Software Foundation, either version 3 of the License, or
+;;;; (at your option) any later version.
+;;;;
+;;;; LilyPond is distributed in the hope that it will be useful,
+;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;;; GNU General Public License for more details.
+;;;;
+;;;; You should have received a copy of the GNU General Public License
+;;;; along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
+
+(define (sort-grob-properties props)
+ ;; force 'meta to the end of each prop-list
+ (let ((meta (assoc 'meta props)))
+ (append (sort (assoc-remove! props 'meta) ly:alist-ci<?)
+ (list meta))))
+
+;; properly sort all properties and interfaces
+;; within the all-grob-descriptions alist
+(set! all-grob-descriptions
+ (map!
+ (lambda (grob-description)
+ (let* ((grob-key (car grob-description))
+ (props (assoc-ref all-grob-descriptions grob-key))
+ (meta (assoc-ref props 'meta))
+ (interfaces (assoc-ref meta 'interfaces))
+ (sorted-ifaces (sort interfaces ly:symbol-ci<?))
+ (new-meta (assoc-set! meta 'interfaces sorted-ifaces))
+ (new-props (assoc-set! props 'meta new-meta))
+ (sorted-props (sort-grob-properties new-props)))
+ (cons grob-key sorted-props)))
+ all-grob-descriptions))
+
+;; sort all grobs in the all-grob-descriptions alist
+(set! all-grob-descriptions (sort all-grob-descriptions ly:alist-ci<?))