The functionality already exists; it needs to be directly exposed. In a private exchange Baptisse (bapt@) has said it wouldn't be hard, but there are higher priorities. I am submitting this pr so it gets on the TODO list.
Can you detail what is pkg_sort?
"pkg_sort" inputs a list of ports - with or without origins or exact versions - and outputs a list of those ports sorted in dependency (if any) order. I believe this exists withing pkg - referred to as the "working list", yes? Input can be from stdin or a file; output is to stdout, in a format suitable for piping directly to {portmaster, portupgrade, etc.}. Does this answer the question?
yes :)
Status?
I still have hier priorities and this is waiting for a volunteer to implement :D