Added sort_by_weight()