Rewrite sort to support handicap