function sorted_vector=kudoh_taguchi_result_sorter(unsorted_vector)
%description: takes events detected by the kudoh-taguchi method in find_multiple_peaks and sorts from largest to smallest
%called by: simulated_psc_in_noise
%calls: [no custom functions]
%notes: find_multiple_peaks returns a single column per sweep; the number of detected events varies
    %find_multiple_peaks returns five values per event, with corrected_peak_amp (peak amp minus onset amp) the last of them
%code confirmed date: nov 4, 2012

num_kt_output_params=5;

unsorted_array=reshape(unsorted_vector,num_kt_output_params,length(unsorted_vector)/num_kt_output_params); %reshape with one event per column

[~,i]=sort(unsorted_array(num_kt_output_params,:),'ascend'); %the 'biggest' peak is the most negative one

sorted_array=unsorted_array(:,i);

sorted_vector=sorted_array(:);