compensate for api bug,
allow io for pretty print
ensure topn is always sorted