Sort by deadline
Extract #call_api to Util module