def by_unit_room_bed(patient):
    return patient.bed.room.unit, patient.bed.room.order, patient.bed.order
patient_list = list(physician.patients)
Sorting and indexing into a list in a Django template?