Added some sorting to result_by_set_length