function content  = sortPageContent(pagecontent)
cntr=1;
rest='dummy';
toparse = pagecontent;
while ~isempty(toparse)
    [rest,toparse]= strtok(toparse,'[');
    if ~isempty(strfind(rest,']'))
        [links2store{cntr,1}]= strtok(rest,']');
        cntr=cntr+1;
    end
end

%% find dirs and mfiles
[iddir,idm]=deal([]);
for i = 1:length(links2store)
    if ~isempty(strfind(links2store{i,1},'.m'));
        idm = [idm;i];
    else
        iddir = [iddir;i];
    end
end

%% first sort dirs
content = [];
if ~isempty(iddir)
    tempdir = links2store(iddir);
    [dummy, tempdirid] = sort(unique(lower(tempdir))); % sort case insensitive
    tempdir = tempdir(tempdirid);                      % store case sensitive 
    content = [];
    for i = 1:length(tempdir)
        content = [content char(13) '*[' tempdir{i} ']*'];
    end
end

%% next sort mfiles
if ~isempty(idm)
    tempm = links2store(idm);
    [dummy, tempmid] = sort(unique(lower(tempm)));     % sort case insensitive
    tempm = tempm(tempmid);                            % store case sensitive 
    for i = 1:length(tempm);
        content = [content char(13) '[' tempm{i} ']'];
    end
end