+;;;;
+;;;; 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 x)
+ ;; force 'meta to the end of each prop-list
+ (let ((meta (assoc 'meta x)))
+ (append (sort (assoc-remove! x 'meta) ly:alist-ci<?)
+ (list meta))))
+
+;; properly sort all grobs, properties, and interfaces
+;; within the all-grob-descriptions alist
+(map
+ (lambda (x)
+ (let* ((props (assoc-ref all-grob-descriptions (car x)))
+ (meta (assoc-ref props 'meta))
+ (interfaces (assoc-ref meta 'interfaces)))
+ (set! all-grob-descriptions
+ (sort (assoc-set! all-grob-descriptions (car x)
+ (sort-grob-properties
+ (assoc-set! props 'meta
+ (assoc-set! meta 'interfaces
+ (sort interfaces ly:symbol-ci<?)))))
+ ly:alist-ci<?))))
+ all-grob-descriptions)