adds sorted metric to top-k, fixes an error in top-k computation