I'm new to WordPress.
When it comes to php, I know essentially nothing. To accomplish things, typically just hack code I've found on the web.

I want to add some additional sortable columns to my administrative Pages and Posts pages (the pages that list all Pages and Posts) via code placed in my child theme's functions.php file.

I added a sortable "last modified" column via the code shown at the very bottom of this posting. It works fine.

I thought I would just hack that code to create a sortable "permalink" column too. (Each of my pages and posts use a custom permalink. I would like that shown and to be able to sort according to it.)

With the code I've devised (copied and hacked), I get the output in the Permalinks column that I want (the permalink URL with the domain portion cut off: www.example.com/one/page-one.html is shown as /one/page-one.html)

But the problem I have is that when I try to sort according to this Permalink column, the information is actually sorted according to each Page's/Post's "published date" data.

Evidently, the information that's held in memory by WordPress and associated with the Permalink column I've created is different than what I've outputted on the page. To WordPress, it seems my Permalink column is populated with post "published date" data.

What have I done wrong? Thanks.
---
This is the code that DOES NOT WORK properly in creating a sortable Permalinks column.

//* Add -Permalink- column on Post and Page admin tables - Start
// Register the column for permalink info
function bf_post_permalink_column_register( $columns ) {
$columns['post_permalink'] = __( 'Permalink', 'mytextdomain' );
return $columns;
}
add_filter( 'manage_edit-post_columns', 'bf_post_permalink_column_register' );
add_filter( 'manage_edit-page_columns', 'bf_post_permalink_column_register' );

// Display the permalink column content
function bf_post_permalink_column_display( $column_name, $post_id ) {
if ( 'post_permalink' != $column_name ){
return;
}
$post_permalink = get_post_permalink();
if ( !$post_permalink ){
$post_permalink = '' . __( 'undefined', 'mytextdomain' ) . '';
}
$home_url = get_home_url();
$home_url_length = strlen($home_url);
$post_permalink = substr($post_permalink, $home_url_length);
echo $post_permalink;
}
add_action( 'manage_posts_custom_column', 'bf_post_permalink_column_display', 10, 2 );
add_action( 'manage_pages_custom_column', 'bf_post_permalink_column_display', 10, 2 );

// Register the permalink column as sortable
function bf_post_permalink_column_register_sortable( $columns ) {
$columns['post_permalink'] = 'post_permalink';
return $columns;
}
add_filter( 'manage_edit-post_sortable_columns', 'bf_post_permalink_column_register_sortable' );
add_filter( 'manage_edit-page_sortable_columns', 'bf_post_permalink_column_register_sortable' );
//* Add -permalink- column - End


---
This is the code that WORKS FINE in creating a sortable "last modified" column.

//* Add -Last Modified- column on Post and Page admin tables - Start
// Register the column for modified date
function bf_post_modified_column_register( $columns ) {
$columns['post_modified'] = __( 'Modified Date', 'mytextdomain' );
return $columns;
}
add_filter( 'manage_edit-post_columns', 'bf_post_modified_column_register' );
add_filter( 'manage_edit-page_columns', 'bf_post_modified_column_register' );

// Display the modified date column content
function bf_post_modified_column_display( $column_name, $post_id ) {
if ( 'post_modified' != $column_name ){
return;
}
$post_modified = get_post_field('post_modified', $post_id);
if ( !$post_modified ){
$post_modified = '' . __( 'undefined', 'mytextdomain' ) . '';
}
echo $post_modified;
}
add_action( 'manage_posts_custom_column', 'bf_post_modified_column_display', 10, 2 );
add_action( 'manage_pages_custom_column', 'bf_post_modified_column_display', 10, 2 );

// Register the modified date column as sortable
function bf_post_modified_column_register_sortable( $columns ) {
$columns['post_modified'] = 'post_modified';
return $columns;
}
add_filter( 'manage_edit-post_sortable_columns', 'bf_post_modified_column_register_sortable' );
add_filter( 'manage_edit-page_sortable_columns', 'bf_post_modified_column_register_sortable' );
//* Add -Last Revision- column - End