What do you mean by topic's first page ?
If I understood you correctly, you mean topic in which there is only 1 page ? if yes, still, we can't say how many topics will be one page (it could be a lot) when site admin have an active forum based users.
I think changing the position automatically when any post is marked as answered makes it non-user friendly since any new user looking for an answer might get confused since the answer is showing first as the new user won't know the order of discussion. A lot of times in forums users do want to read the discussion in order to know what's happening..
Could you please help me with this in code ? How to do that and where ? which page ? where to get code for the method ? and change to what ?