Sorting each value in a list of data?

I’m working on categorizing and sorting images with AI.
I passed a list of images to the AI through the API and received a list of dog, cat, and bird classifications for each image.

ex) And I have the following data
images : "image1,image2,image3,image4
labeled : “dog,cat,bird,cat”

I want to change this list of images to a list of images in the order cat, bird, dog.

Desired result: “image2, image4, image3, image1”

Please help me how to do this

How are you defining the sort order?

cat, bird, dog

Yeah I know that… but what’s the logic behind it? (in other words, how are you deciding that’s the order you need)?

If there’s no logic, and you already know the order, then just do it manually (but I’m guessing that’s not what you’re tyring to do).

I got labeling from API so can’t do it manually…

So what’s the criteria?