refactor to enable different score function
fix sorter to support both desc and asc order