How to export object list to text ordered by name?
bpy.context.selected_objects is a list of objects, it is not guaranteed to be in any specific order, to get the list in order you need to sort it yourself.

Python has the builtin function sorted() to sort lists. As it can't sort objects directly you need to specify a key function that can provide a sortable key. Using the example from pythons Sorting How-To you can use attrgetter() to get the objects name attribute to use for sorting.

import bpy
from operator import attrgetter

for obj in sorted(bpy.context.selected_objects, key=attrgetter('name')):
    print(obj.name)