There is a naive, but surprisingly effective way, to solve the ordering problem: keep running each script. An individual script will either eventually work (after other scripts are run first) or fail > # of scripts (in which case, it's a bad script). You may be able to detect a bad script quicker/easier - but I've never needed to.
If you have 1 giant script, it's probably split by GO statements. It should be enough to run it as many times as there are unique GO statements. Any attempts to CREATE an object that already exists will fail, and abort the batch. The next batch will run uninterrupted. Eventually, you have the necessary objects created - and rerunning the entire script will create the dependent object (and fail on the already created independent objects). You'll never get the script to run without errors, though.
If you want to get a bit fancier, you can split the giant script into individual batches and run them individually. Now, you can track what order is needed to get them to work. Just recombine them in that order, and output the new script. It should run without errors.
Or, spend the $500 to buy a tool that already does this (RedGate, Visual Studio Ultimate/Database Edition, etc.).