fix logical error of Sorting.isSorted(arr, f)

the previous code has ignored the check of last item
fix this ignorance and add an unit test