A Pakistani court has ordered the release of ex-Prime Minister Nawaz Sharif, two months after he began a 10-year jail sentence over corruption.