
    Given a matrix of patient health metrics where each row contains different risk factors and the sum of each row represents their readmission risk score, create a function that sorts patients in ascending order based on their total risk scores. The sorted output should maintain the relationship between each patient's individual risk factors while organizing them from lowest to highest overall risk, enabling healthcare providers to efficiently prioritize patient interventions.
    

    
def sort_matrix(M):
    """
    Given a matrix of patient health metrics where each row contains different risk factors and the sum of each row represents their readmission risk score, create a function that sorts patients in ascending order based on their total risk scores. The sorted output should maintain the relationship between each patient's individual risk factors while organizing them from lowest to highest overall risk, enabling healthcare providers to efficiently prioritize patient interventions.
    

    """
def sort_matrix(M):
    """
    Given a matrix of patient health metrics where each row contains different risk factors and the sum of each row represents their readmission risk score, create a function that sorts patients in ascending order based on their total risk scores. The sorted output should maintain the relationship between each patient's individual risk factors while organizing them from lowest to highest overall risk, enabling healthcare providers to efficiently prioritize patient interventions.
    

    """
    result = sorted(M, key=sum)
    return result