selection history from "shortest path"?
this script will help you

import bpy, bmesh

print("*"*50)
oa = bpy.context.active_object
obj = bpy.context.object

bpy.ops.mesh.shortest_path_select() #add for request

me = obj.data
bm = bmesh.from_edit_mesh(me)


v1,v2 = [elem for elem in bm.select_history if isinstance(elem, bmesh.types.BMVert)]

list = [v1]
verts = len([v.index for v in bm.verts if v.select])

cont=0

while cont&lt; verts:
    v=list[cont]
    edges = v.link_edges

    for e in edges:
        if e.select:
            vn = e.other_vert(v)
            if vn not in list:
                list.append(vn)

    cont+=1

print(list)

for v in list:
    print(v.index)
bmesh.update_edit_mesh(me, True)