         }
         
         // Blood pressure log is required.
-        guard let bloodPressureMeasurements = decoder.decodeObject(forKey: PropertyKey.bloodPressureMeasurements) as? [BloodPressureMeasurement] else {
+        guard let bloodPressureMeasurementsSorted = decoder.decodeObject(forKey: PropertyKey.bloodPressureMeasurementsSorted) as? [BloodPressureMeasurement] else {
+            
             os_log("Unable to decode the blood pressure log for a Patient object.", log: OSLog.default, type: .debug)
             return nil
         }

        encoder.encode(birthDate, forKey: PropertyKey.birthDate)
        encoder.encode(heightInMeters, forKey: PropertyKey.heightInMeters)
        encoder.encode(sexInBoolean, forKey: PropertyKey.sexInBoolean)
        encoder.encode(bloodPressureMeasurements, forKey: PropertyKey.bloodPressureMeasurements)
    }
    
    public required convenience init?(coder decoder: NSCoder) {

    var birthDate: Date
    var heightInMeters: Float
    private var sexInBoolean: Bool
    private var bloodPressureMeasurementsSorted: [BloodPressureMeasurement]
    public var bloodPressureMeasurements: [BloodPressureMeasurement] {
        get {
            return self.bloodPressureMeasurementsSorted
        }
        
        set(newBloodPressureMeasurements) {
            self.bloodPressureMeasurementsSorted = newBloodPressureMeasurements.sorted {
                return $0.measurementDate < $1.measurementDate
            }
        }
    }
    
    public var sex: Patient.Sex {
        get {
