def two_sum(nums: List[int], target:Int) -> Tuple[int, int]:
indexed_nums = sorted((n, i) for i, n in enumerate(nums))
left, right = 0, len(indexed_nums) - 1
while left < right:
current_sum = indexed_nums[left][0] + indexed_nums[right][0]
if current_sum == target:
return (indexed_nums[left][1], indexed_nums[right][1])
elif current_sum < target:
left += 1
else:
right -= 1
return (-1, -1)