Sort keys when formatting attributes