Fixes flag ordering issues.

Prior to this commit, there were 2 issues.  Now, ldflags are not re-ordered,
which would be wrong in general, and cflags are sorted for applications