Let's say we have a module that has a register file currently inside that can hold 3 numbers. Suppose the three numbers are: 4, 6, 7. 4 is at index 0, 6 is at index 1, and 7 is at index 2. A new number, 5, comes in. The module has 4 outputs, where the numbers are always sorted.
The obvious way to do this is to have three comparators in cascade. The number comes in, gets compared with the first number, the bigger one gets propagated and becomes one of the inputs to the next comparator, and so on.
The above solution works, but since the comparators are in cascade, the speed is dictated by how many elements we have inside the module. Also, I feel this method doesn't exploit the fact that the numbers are already in sorted order.
Another approach is to use a shift register. But this requires us to use a clock and also wait one clock cycle since registers get updated one clock cycle later. This is supposed to be a combinatorial circuit.
I was thinking of a third solution where we would compare the number with numbers in the module at once. This would give us something like 0, 1, 1. We could then use this as the inputs to a cascade of multiplexers to numbers. I'm not sure if this is faster than the comparator cascade structure I mentioned above.
Any better ideas are appreciated.