Custom sorting

Good afternoon!
We need to do custom sorting in elastic. You need to give elastic a list of document IDs as input, according to which you need to sort the output. That is, we first sort by this list (to the top of the output), and the remaining output by another field in the elastic. How can I do that?

Thanks for reaching out, @alexander.korkhov. Would something like this work for you?