You need to first perform non-maximal suppression and then sort the remaining data.
Try this ...
x = 1:100;
Answered 3 years ago
Just type "dct2" in an editor window. Then right click it an select "open dct2". The code is there.