Index: trunk/MagicSoft/Mars/mbase/MDirIter.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MDirIter.cc	(revision 5143)
+++ trunk/MagicSoft/Mars/mbase/MDirIter.cc	(revision 5144)
@@ -350,2 +350,31 @@
     }
 }
+
+// --------------------------------------------------------------------------
+//
+// Loop over all contents (files). Sort the files alphabetically.
+// Delete the contents of this DirIter and add all sorted files
+// to this DirIter.
+//
+void MDirIter::Sort()
+{
+    MDirIter Next(*this);
+
+    TList l;
+    l.SetOwner();
+
+    TString name;
+    while (!(name=Next()).IsNull())
+        l.Add(new TNamed(name.Data(), ""));
+
+    l.Sort();
+
+    fList.Delete();
+    Close();
+    fFilter = "";
+
+    TIter NextN(&l);
+    TObject *o=0;
+    while ((o=NextN()))
+           AddDirectory(o->GetName());
+}
Index: trunk/MagicSoft/Mars/mbase/MDirIter.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MDirIter.h	(revision 5143)
+++ trunk/MagicSoft/Mars/mbase/MDirIter.h	(revision 5144)
@@ -48,4 +48,6 @@
     }
 
+    void Sort();
+
     Int_t AddDirectory(const char *dir, const char *filter="", Int_t recursive=0);
     void  Add(const MDirIter &iter);
