Simple TopK operator in JS