I would be interested if you could expand on how you would alter the NN architecture for different sized lists
I mean it might technically be possible if you did some kind of recurrent neural network and gave the inputs through time rather than through space. And you would also have to let it interact with some kind of external memory or workspace.
Perhaps you could train it to just perform operations on the list itself (compare two elements, swap two elements, etc.) That would be the simplest way.