I probably should have returned and posted my solution for other's reference.
The problem I found with trying to set a variable was I didn't (and still don't) completely understand how the user data is being generated when the user is a guest.
The code that determines the sort order is in SHOWTHREAD.PHP. The value it uses is the guest user's "postorder" variable ($vbulletin->userinfo['postorder']). The standard guest user name in the version that comes out of the box is "Unregistered". I don't have a user with the user name "Unregistered" so obviously vBulletin is doing something on authentication to create that user and its information. I don't know if there's something else in the admin portions of vBulletin that allows one to set the "Unregistered" user's default info or not, but I couldn't find it if there is.
Doing this from a hook seems to be problematic. You have to be able to set the $vbulletin->userinfo['postorder'] to '' (empty string) to make it work (see the code below for how it generates the sort order for the query), but when I tried to do this in a plug-in, using the 'showthread_start' hook, I got no changes in my sort order. Maybe this property unassignable, or the user (or its information) gets recreated every postback because it's not a database user? I don't know.
What I did to solve the problem was to hack the SHOWTHREAD.PHP file thusly:
Find this code ("set post order" should find it directly):
PHP Code:
// set post order
if ($vbulletin->userinfo['postorder'] == 0)
{
$postorder = '';
}
else
{
$postorder = 'DESC';
}
and change it to this:
PHP Code:
// set post order
if ($vbulletin->userinfo['postorder'] == 0 AND $vbulletin->userinfo['username'] != 'Unregistered')
{
$postorder = '';
}
else
{
$postorder = 'DESC';
}
NOTE that I read something about the user name for language packs other than the default English may well have other user names than "unregistered" and therefore may not work in those situations.
As far as going further with highest rated threads sorting and/or promoting threads - you can see where to make the changes to the sort order itself, but it will be a bit more complex than I laid out than for just a user that's not logged in. You will obviously have to get the other info you are interested in and make the conditional fit your needs.