]> Creatis software - CreaPhase.git/blobdiff - octave_packages/strings-1.1.0/strsort.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / strings-1.1.0 / strsort.m
diff --git a/octave_packages/strings-1.1.0/strsort.m b/octave_packages/strings-1.1.0/strsort.m
new file mode 100644 (file)
index 0000000..450f2ba
--- /dev/null
@@ -0,0 +1,19 @@
+## Author: Paul Kienzle <pkienzle@users.sf.net>
+## This program is granted to the public domain.
+
+## -*- texinfo -*-
+## @deftypefn {Function File} {[@dots{}] =} strsort (@dots{})
+## Overloads the sort function to operate on strings.
+##
+## @seealso {sort}
+## @end deftypefn
+
+# PKG_ADD dispatch ("sort", "strsort", "string")
+function [sorted,idx] = strsort(string,varargin)
+  if nargout == 2
+    [s,idx] = sort(toascii(string),varargin{:});
+  else
+    s = sort(toascii(string),varargin{:});
+  endif
+  sorted = char(s);
+endfunction