Where does finding and sorting photos for the Instagram Stories feature happen?

On the server.On the Instagram app.

That's right!

The server finds and sorts the photos using Instagram's database.