Why not binary search has sort inside the function?
Why the list is not sorted in the function?
As Giles mentioned we have sorted list (during description), so that comparing values respective to midpoint will be logically true.
I see no sort happening in the function but sorting the list which is argument.
Isn't the base of binary search algorithm depends on sorted list?
Thank you for your question!
You can definitely add one more line in the body of the function which sorts
my_list. The way Giles has decided to do it, however, is to assume that the list is already sorted before feeding it into the algorithm. Either way works :)