inner foreach loop sorting

It looks like all you need to do is change toe orderby argument of your wp_get_object_terms() call. After all, that’s what you’re looping through further down.

If you change 'orderby' => 'ID' to 'orderby' => 'name', your terms will be ordered alphabetically.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)