matthiasm@8: % ASORT matthiasm@8: % a pedestrian NUMERICAL SORTER of ALPHANUMERIC data matthiasm@8: matthiasm@8: % - create some data matthiasm@8: d = { matthiasm@8: % strings with one valid alphanumeric number matthiasm@8: % sorted numerically matthiasm@8: '-inf' matthiasm@8: 'x-3.2e4y' matthiasm@8: 'f-1.4' matthiasm@8: '-.1' matthiasm@8: '+ .1d-2' matthiasm@8: '.1' matthiasm@8: 'f.1' matthiasm@8: 'f -+1.4' matthiasm@8: 'f.2' matthiasm@8: 'f.3' matthiasm@8: 'f.10' matthiasm@8: 'f.11' matthiasm@8: '+inf' matthiasm@8: ' -nan' matthiasm@8: '+ nan' matthiasm@8: 'nan' matthiasm@8: % strings with many numbers or invalid/ambiguous numbers matthiasm@8: % sorted in ascii dictionary order matthiasm@8: ' nan nan' matthiasm@8: '+ .1e-.2' matthiasm@8: '-1 2' matthiasm@8: 'Z12e12ez' matthiasm@8: 'inf -inf' matthiasm@8: 's.3TT.4' matthiasm@8: 'z12e12ez' matthiasm@8: % strings without numbers matthiasm@8: % sorted in ascii dictionary order matthiasm@8: ' . .. ' matthiasm@8: '.' matthiasm@8: '...' matthiasm@8: '.b a.' matthiasm@8: 'a string' matthiasm@8: 'a. .b' matthiasm@8: }; matthiasm@8: % ... and scramble it... matthiasm@8: rand('seed',10); matthiasm@8: d=d(randperm(numel(d))); matthiasm@8: matthiasm@8: % - run ASORT with matthiasm@8: % verbose output: <-v> matthiasm@8: % keep additional results: <-d> matthiasm@8: o=asort(d,'-v','-d'); matthiasm@8: % - or matthiasm@8: % p=asort(char(d),'-v','-d'); matthiasm@8: matthiasm@8: % - show results matthiasm@8: o matthiasm@8: o.anr matthiasm@8: matthiasm@8: % - run ASORT with no-space/template options matthiasm@8: % NOTE the impact of -w/-t order! matthiasm@8: s={'ff - 1','ff + 1','- 12'}; matthiasm@8: % RAW matthiasm@8: o=asort(s,'-v'); matthiasm@8: % remove SPACEs matthiasm@8: o=asort(s,'-v','-w'); matthiasm@8: % remove TEMPLATE(s) matthiasm@8: o=asort(s,'-v','-t',{'ff','1'}); matthiasm@8: % remove TEMPLATE(s) than SPACEs matthiasm@8: o=asort(s,'-v','-t','1','-w'); matthiasm@8: % remove SPACEs than TEMPLATE(s) matthiasm@8: o=asort(s,'-v','-w','-t','1'); matthiasm@8: