0001 function evs = pr_sort_evs(evs, sort_type, downf)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 if nargin < 2
0017 error('Need event specs and sort type');
0018 end
0019 if nargin < 3
0020 downf = 0;
0021 end
0022
0023 e_s = [evs.e_spec]';
0024
0025 switch lower(sort_type)
0026 case {'session no', 'session'}
0027 [tmp I] = sortrows(e_s);
0028 case {'event no', 'event'}
0029 [tmp I] = sortrows(e_s, [2 1]);
0030 case {'event name', 'name'}
0031 [tmp I] = sort(evs.names);
0032 otherwise
0033 error(['Crazy sorting too much with ' sort_type]);
0034 end
0035
0036 if downf, I = flipud(I); end
0037
0038 evs.names = evs.names(I);
0039 evs.e_spec = evs.e_spec(:, I);
0040
0041 return