MATLAB: Sort(x) doesn’t work properly.

sort

Why when I'm trying to sort , at the end there are numbers that are not sorted?

Best Answer

How do you know it is not sorted. The following code shows that it is indeed sorted
daily_logreturns_sorted = sort(daily_logreturns);
tf = all(diff(daily_logreturns_sorted)>=0)
Result
>> tf
tf =
logical
1