Time complexity of sorting algorithm