okay, yes indeed.
the replacement should be:
'first_post' => 't.id_topic',
'last_post' => 't.id_last_msg'
to:
'first_post' => 'mf.poster_time',
'last_post' => 'ml.poster_time'
and this redefines the sorting order for last message (from message id to last post time) and first message (from topic id to first post time).
and, same file:
FROM {db_prefix}topics AS t' . ($sort_by === 'last_poster' ? 'to:
FROM {db_prefix}topics AS t' . (in_array($sort_by, array('last_poster', 'last_post') ? 'this should join the messages table (last => ml) for both last_poster and last_post (as modified above).
and:
in_array($sort_by, array('starter', 'subject'))to:
in_array($sort_by, array('starter', 'subject', 'first_post'))to join the message table (first => mf) for all the cases, including the above modified first_post.
again, not tested (i'm working on other stuff and i don't have handy a good place to test)... sorry.