The only ways I could think of are too complicated, when I feel like there is surely an easy way.
I would do it with a global variable, and that is what I don't like, to have something external like that. Since, if different Objects get plentysome, I'd end up with loads of global variables just for ordering the instances of each Object.
I would basically do something like this:
We have:
+ globalvar('IDCounter') = 0
+ SpriteObject
+ SpriteObjectVar('IndexID') = 0
We do:
+ For Each SpriteObject (Ordered by SpriteObject.UID - Ascending)
-> Add +1 to global('IDCounter')
-> SpriteObject.SetValue('IndexID') = global('IDCounter')
Thank You in advance.