#!/usr/bin/octave -qf % Copyright 2005 Daniel Cer (daniel.cer@cs.colorado.edu) % % This work is licensed under the Creative Commons Attribution-NonCommercial- % ShareAlike License. To view a copy of this license, visit % http://creativecommons.org/licenses/by-nc-sa/2.5/ or send a letter to % Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, % 94105, USA. if nargin == 0, fprintf(stderr, "Usage:\n\t%s (file with numbers to sort)\n", program_name); exit(-1); endif if (fh = fopen(argv{1})) == -1, fprintf(stderr, "Can't open \"%s\"\n", argv{1}); exit(-1); endif % read in the items items = []; line = fgetl(fh); while !feof(fh), item = str2num(line); items = [items, item]; line = fgetl(fh); endwhile fclose(fh); % sort them items = sort(items); % display the results for i=1:size(items,2), disp(items(1,i)); endfor