Two buyers of land property

Seller sold his agricultural land to individual party A but non cooperative to register,A took seller to apex City Civil Court & got orders for the execution & got orders in his favour for getting him registered as owner & also injunction for any further third party selling.Later ignoring this, the seller once again sold to the party company B with registration,by hiding the fact of first sell & B further made it NA for industrial purpose under different record of rights for the same property Because of still non cooperative attitude of the seller,court permitted execution by registering the property with court commissioner as seller with registration at latter date due to delay then that of party B. Later party A sold the land with registration to the third party as a lawful seller,party B objected to this sale saying they are the owners having the first document with registration here & threatened with cancellation of registration of party A within court. Here whom can be regarded as a legitimate owner A or B,please give your advise