Preserve user supplied JOIN order

JOIN clauses order is important, previous implementation has always put string or arel joins at the end (after auto-generated association joins).

Fixes #12953, #15488, #16635.

/cc @tenderlove
Special cases here feel dubious, brittle. Have to trace back the param that's being passed and how it can end up being each of these types.