results o(nlogn)