script to sort promises