use sort and then merger method to find nearest point