if you change the layout_id in the table portal_pages (for the dotlrn_class_instance type for example) then when you create a new class the order of the page change.
So i've change the portal__new function to add "order by sort_key" :
-- now insert the pages from the portal template
for v_page in select *
from portal_pages
where portal_id = p_template_id order by sort_key
.....
-- now get the elements on the templates page and put them on the new page
for v_element in select *
from portal_element_map
where page_id = v_page.page_id order by sort_key
maybe it could help someone.
Denis