Sort:  

From the list of users who up vote each lottery post... then the program checks if the extracted user comply with the second rule of the lottery (resteem the lottery post) and if everything is ok, the user is declared winner. Same with the second prize and third prize..

Thanks for the clarification. Upvoted & resteemed.

hello, maybe take a look at my posts ;)