--- Quote Start ---
I think you can either sort the entries in RAM (e.g. using the well-known bubble sort algorithm), or build up an index table and output a sorted stream using this index. I don't see a third method.
But anyway, let's look for the results.
--- Quote End ---
The post is about two streams of data (duration and code). if I have one stream e.g. : 2,6,1,0,7,9,14,1,3,1,6 ...etc
I can sort it using one ram of say depth 16, 3 bit width.
each data arrives as address, I run counter on the 3 bits data(read 0, increment, write back into ram) thus I get in the ram at the end of data set:
location:data
0: 1
1:3
2:1
3:1
4:0
5:0
6:2
7:1
8:0
9:1
10:0
11:0
12:0
13:0
14:1
15:0
hence when I read ram back in ascending address order I get:
0,1,1,1,2,3,6,6,7,9,14
I think it is sorted now