simplify sortByWeight