How to sort layouts order by print order in a list

Hello,I wrote a script to rename several layouts with serial names.
Exmaple:
form
image
to
image

now it works,but when I change these layouts print order,
image
It turned like this:
image

I reconized that the layouts order in python’s list were sort by create time,
not by print order.

Please teach me how to sort layouts order by print order in a list?

import Rhino 
import Rhino.Geometry as rg
import scriptcontext as sc
import rhinoscriptsyntax as rs
import math

sc.doc = Rhino.RhinoDoc.ActiveDoc

def RenameLayootWithSerialName():
    layouts = rs.ViewNames(False,1)
    prefix = rs.GetString("input prefix of layout",False,False)
    
    for i in range(len(layouts)):
        newname = str(prefix)+'-'+str(i+1).zfill(2)
        rs.RenameView(layouts[i],str(newname))


RenameLayootWithSerialName()

Hello, I can’t help you with your script. But I came across this little pythonscript a while back for publishing layout sheets, it might be helpful. If you have dots in your drawing it doesn’t like them very much either. This is why we need better native publishing tools inside Rhino along with table generation too.
batch plot layoutov rhino.py (802 Bytes)
(apologies to the author of the script, I can’t recall who wrote it)