If, upon the hearing pursuant to sections 495 and 496 of this title, the court finds that it is necessary that the real property, or any portion thereof, should be sold it shall make the order accordingly, and prescribe the terms thereof, whether of cash or credit, or both. If such property can not be divided without probable injury and loss to the estate it may order that the property, or any specific lot or portion thereof, shall be sold wholly, whether otherwise necessary or not.