The input stream should ensure that it have same number of key and pld. The internal design is based on insert sort algorithm. The algorithm implemention is shown as the figure below: Figure 1 : Architecture of Top K Sort