85:7 A Torah scroll should be rescued before any other sacred book. (Furthermore, books of Tanach should be saved before books of Oral Law, like Mishna and Gemara. A deceased person's mortal remains should be saved before holy texts - Mishnah Brurah 334:30.)
85:8 When there is even a small possibility of danger to human life, one may put out a fire on Shabbos. In a place where Jews live next to non-Jews, it is permissible to put out the fire even in a non-Jew's home, though every situation must be evaluated based upon its own particulars. A fire may be extinguished to save life but one may not violate Shabbos in order to rescue property. If one did violate Shabbos in such circumstances, he should consult a rav for advice on how he might rectify this misdeed.