Sort and escape HTML attributes

Escape method from ERB. Attribute sorting for predictability.