Based in this answer to Getting features in order they are selected using PyQGIS?, I ran following code at Python Console of QGIS 3 for getting features id in order they were selected.
def onSelectionChanged():
try:
id = iface.activeLayer().selectedFeatures()[0].id()
print (id)
except IndexError:
print ("no feature selected")
iface.activeLayer().selectionChanged.connect( onSelectionChanged )
I tried above code out with shapefile visualized at following image, where docked attributes table was used to corroborate that printed values at Python Console had correct order.
How can I modify my function for storing printed id values at Python Console of QGIS, as a list variable, without using a file written on disk drive?