There is no pytorch function that can do what you are looking for. So you have to use a for loop. Your implementation can be made more efficient by creating a new tensor and then copying the contents to it, rather than increasing the current tensor by using cat.
def sort_tensor(tensor):
    tensor_pooled = nn.AdaptiveAvgPool2d(1)(tensor).squeeze()
    
    _, sorted_indx = torch.sort(tensor_pooled, 1, descending=True)
    
    # Create a new tensor where the result would be stored
    sorted_tensor = torch.empty(tensor.size())
    for dim_0 in range(tensor_pooled.shape[0]):
        for dim_1 in range(tensor_pooled.shape[1]):
            sorted_tensor[dim_0, dim_1] = tensor[dim_0, sorted_indx[dim_0, dim_1]]
    
    return sorted_tensor