ar を使用して構築しているときに静的ライブラリ中の要素を整列するには、コマンド lorder(1) と tsort(1) を使用します。
demo% ar -cr mylib.a 'lorder exg.o fofx.o diffz.o | tsort'