There seems to be a lot of confusion here about allowable withdrawals from 401k plans prior to age 59 1/2. One can rollover their 401k into an IRA when they terminate employment. Some plans will provide, at the employer's discretion, in-service withdrawals for those who want some of their money before they leave the employer. However, this usually is allowed only under HARDSHIP conditions (medical costs, prevent foreclosure, etc.) and only after you have exhausted other avenues. IRA's do not have these "hardship" restrictions. But rolling your 401k, before you terminate and before age 59 1/2, into an IRA to avoid these hardhip restrictions is generally not allowed.
If you made DEDUCTIBLE IRA contributions, then ALL of your IRA withdrawals are taxable (not just the earnings). Conversely, qualified withdrawals from 529's and Roth's are non-deductible but TAX-FREE. In most cases, the younger you are, advantage to the latter.
Another consideration as to which plan to fund first has to do with any employer match in the 401k. This is "free" money, which you can not get anywhere else. So, the answer to the original question posed, as usual, is "it depends". Know what your 401k plan does and does not allow in terms of withdrawals, know the tax implications, consider your time frame, and then decide. Bottom line is that ANY savings is good, so you are better off no matter which route you go vs. not saving at all.