function [listrev,ii] = strsort(slist); % function [listrev,ii] = strsort(slist); % sorts a list of strings % slist: strings, one per row % listrev: list in ascending order % ii: indexes of strings from original list % copyright, 1996, William F. Sharpe % wfsharpe@leland.stanford.edu % this version Jan. 15, 1996 % convert to numeric of upper case and turn on side s = abs(upper(slist))'; % entries are in columns nr = size(s,1); nc = size(s,2); ngt = zeros(nc,1); for col = 1:1:nc % make column matrix and subtract colv = s(:,col); colm = colv*ones(1,nc); % get first gt cmpgt = colm>s; [y,firstgt] = max(cmpgt); % if sum(cmpgt) == 0, it isn't gt anything testv = 99999*(sum(cmpgt)==0); firstgt = firstgt + testv; % get first lt cmplt = colm