The input stream should ensure that it has the same number of key and pld. The internal design is based on inserting sort algorithm. The algorithm implementation is shown in the following figure: Figure 1 : Architecture of Top K Sort