 <p>Humm. Is your sort truly async or does it just take a function as a parameter? Also, I think we will need a bit more information regarding the workunit.sort method.</p> <p>Anyhow, as a high level, you can use something like <code>async</code> module to wait for the completion of async tasks perhaps?</p>