
    Given a matrix where each row represents a user's engagement metrics (likes, shares, comments) across different content categories, rearrange the rows based on users' total engagement scores in ascending order. This sorting will help identify users with similar interaction patterns and improve content recommendations by grouping users with comparable engagement levels.
    

    
def sort_matrix(M):
    """
    Given a matrix where each row represents a user's engagement metrics (likes, shares, comments) across different content categories, rearrange the rows based on users' total engagement scores in ascending order. This sorting will help identify users with similar interaction patterns and improve content recommendations by grouping users with comparable engagement levels.
    

    """
def sort_matrix(M):
    """
    Given a matrix where each row represents a user's engagement metrics (likes, shares, comments) across different content categories, rearrange the rows based on users' total engagement scores in ascending order. This sorting will help identify users with similar interaction patterns and improve content recommendations by grouping users with comparable engagement levels.
    

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