You didn’t share the data you have so I’m assuming tag is a simple text field. You may need to adjust it to match your data…
$pages = $pages->map(function($page) {
// convert tag name to array
$tag = explode(' ', $page->tag()->value());
// take last item of the array
$page->lastname = array_pop($tag);
return $page;
})->sortBy('lastname');
dump($pages);
So this is basically adding a new field to each item in the collection so that you can sort it by the new field.