Fixed #23660 -- Moved sort_dependencies to core.