when you create a sprite, select it and on the left pane (properties) you should have the ability to add a new instance variable to it, add it, call it "whatever" :)
then in the event sheet when you create the sprite just set its "whatever" instance variable to the floor(random(9999)) and in the next event make a foreach ordered, choose the sprite, ordered by expression sprite.whatever ascending