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 sorteddaily_logreturns_sorted = sort(daily_logreturns);tf = all(diff(daily_logreturns_sorted)>=0)Result>> tftf = logical 1 Related SolutionsMATLAB: About unique command problem Doc says: [C,ia,ic] = unique(A,setOrder) and [C,ia,ic] = unique(A,'rows',setOrder) returns C in a specific order. setOrder='sorted' returns the values (or rows) of C in sorted order. setOrder='stable' returns the values (or rows) of C in the same order as A.Try setOrder='stable' MATLAB: How to sort the max values from a matrix [~, order] = sort(Occurences.Momentum(:, 2), 'descend');top80 = Occurences.Momentum(order(1:80), :)Or:sortedData = sortrows(Occurences.Momentum, 2, 'descend');top80 = sortedData(1:80, :) Related QuestionWhich function returns the order of a transfer functionHow to call a function properly.Histogram plot isn’t shown properly.
Best Answer