That will be in reporting/rep707.php.
The relevant code is:
function print_profit_and_loss_statement()
The loop is in line 288 within which the elements will need to be alphabetically arranged:
while ($accounttype=db_fetch($typeresult))
Line 273:
$classresult = get_account_classes(false, 0);
too could be checked out.
The lines 40-41 in function display_type
$result = get_gl_accounts(null, null, $type);
while ($account=db_fetch($result))
may need to be sorted for your needs.
A modified version of the rep707.php could be made into an extension to serve your needs. Anyone game?