move sort_by_rank functionality into respective classes