[templates] ensure consistent ordering for extract_attributes