MATLAB: How to find the 4 most extreme values in each column of a matrix

indexing

I have [~,index] = max(abs(A)); absmax = A(sub2ind(size(A),index,1:size(A,2)));
which returns the most extreme value in each column of my matrix but how can I edit this to have it return the 4 most extreme values (pos or neg) from each column?
Thanks!

Best Answer

[~, index] = sort(abs(A), 'descend');
absmax = A(sub2ind(size(A), index(1:4, :), repmat(1:size(A, 2), 4, 1)));