Could you create a temp variable and then use (albeit a slow way) a bubble sort?

You should be able to find the algorithm easily, and then converting to assembler should not be a problem.