Simplify sorting of fragments

Made the current test not include loops since that isn't a requirement.
Got rid of initial sorting since that's not needed.  Return the first
candidate that doesn't have any dependencies.  If there are no
candidates without dependencies, return the one with fewest
dependencies.