added timsort + refactor