Custom post type sortable columns when column value is from a custom database value

You can sort the results based on your custom table data by applying a custom filter to your existing query using the “posts_orderby” hook (untested example code):

add_filter('posts_orderby', 'edit_posts_orderby');

function edit_posts_orderby($orderby_statement) {
    $orderby_statement = "views DESC";
    return $orderby_statement;
}

Source: based on user comment at:
https://developer.wordpress.org/reference/hooks/posts_orderby/

tech