1e3a0241228b5e7c07ff9711b5101b9e5c5b7533
 TvEngine3/Mediaportal/TV/TvPlugin/TVScheduler.cs | 69 ++++++++++++++++++++----
 1 file changed, 59 insertions(+), 10 deletions(-)

diff --git a/TvEngine3/Mediaportal/TV/TvPlugin/TVScheduler.cs b/TvEngine3/Mediaportal/TV/TvPlugin/TVScheduler.cs
index 66b7aec..5501a51 100644
--- a/TvEngine3/Mediaportal/TV/TvPlugin/TVScheduler.cs
+++ b/TvEngine3/Mediaportal/TV/TvPlugin/TVScheduler.cs
@@ -63,7 +63,9 @@ namespace Mediaportal.TV.TvPlugin
     [SkinControl(11)] protected GUICheckButton btnSeries = null;
 
     private SortMethod currentSortMethod = SortMethod.Date;
+    private SortMethod currentSortMethodSeries = SortMethod.Name;
     private bool m_bSortAscending = true;
+    private bool m_bSortAscendingSeries = true;
     private int m_iSelectedItem = 0;
     private bool needUpdate = false;
     private ScheduleBLL selectedItem = null;
@@ -106,7 +108,24 @@ namespace Mediaportal.TV.TvPlugin
             currentSortMethod = SortMethod.Name;
           }
         }
+        strTmp = (string)xmlreader.GetValue("tvscheduler", "sortseries");
+        if (strTmp != null)
+        {
+          if (strTmp == "channel")
+          {
+            currentSortMethodSeries = SortMethod.Channel;
+          }
+          else if (strTmp == "date")
+          {
+            currentSortMethodSeries = SortMethod.Date;
+          }
+          else if (strTmp == "name")
+          {
+            currentSortMethodSeries = SortMethod.Name;
+          }
+        }
         m_bSortAscending = xmlreader.GetValueAsBool("tvscheduler", "sortascending", true);
+        m_bSortAscendingSeries = xmlreader.GetValueAsBool("tvscheduler", "sortascendingseries", true);
         if (btnSeries != null)
         {
           btnSeries.Selected = xmlreader.GetValueAsBool("tvscheduler", "series", false);
@@ -130,7 +149,20 @@ namespace Mediaportal.TV.TvPlugin
             xmlwriter.SetValue("tvscheduler", "sort", "name");
             break;
         }
+        switch (currentSortMethodSeries)
+        {
+          case SortMethod.Channel:
+            xmlwriter.SetValue("tvscheduler", "sortseries", "channel");
+            break;
+          case SortMethod.Date:
+            xmlwriter.SetValue("tvscheduler", "sortseries", "date");
+            break;
+          case SortMethod.Name:
+            xmlwriter.SetValue("tvscheduler", "sortseries", "name");
+            break;
+        }
         xmlwriter.SetValueAsBool("tvscheduler", "sortascending", m_bSortAscending);
+        xmlwriter.SetValueAsBool("tvscheduler", "sortascendingseries", m_bSortAscendingSeries);
         xmlwriter.SetValueAsBool("tvscheduler", "series", btnSeries.Selected);
       }
     }
@@ -208,7 +240,7 @@ namespace Mediaportal.TV.TvPlugin
         dlg.AddLocalizedString(268); //title
 
         // set the focus to currently used sort method
-        dlg.SelectedLabel = (int)currentSortMethod;
+        dlg.SelectedLabel = (int)(btnSeries.Selected ? currentSortMethodSeries : currentSortMethod);
 
         // show dialog and wait for result
         dlg.DoModal(GetID);
@@ -217,7 +249,14 @@ namespace Mediaportal.TV.TvPlugin
           return;
         }
 
-        currentSortMethod = (SortMethod)dlg.SelectedLabel;
+        if (btnSeries.Selected)
+        {
+          currentSortMethodSeries = (SortMethod)dlg.SelectedLabel;
+        }
+        else
+        {
+          currentSortMethod = (SortMethod)dlg.SelectedLabel;
+        }
         OnSort();
       }
       if (control == listSchedules)
@@ -376,10 +415,13 @@ namespace Mediaportal.TV.TvPlugin
         return 1;
       }
 
-      switch (currentSortMethod)
+      SortMethod sortMethod = (btnSeries.Selected ? currentSortMethodSeries : currentSortMethod);
+      bool sortAscending = (btnSeries.Selected ? m_bSortAscendingSeries : m_bSortAscending);
+
+      switch (sortMethod)
       {
         case SortMethod.Name:
-          if (m_bSortAscending)
+          if (sortAscending)
           {
             iComp = String.Compare(rec1.ProgramName, rec2.ProgramName, true);
             if (iComp == 0)
@@ -405,7 +447,7 @@ namespace Mediaportal.TV.TvPlugin
           }
 
         case SortMethod.Channel:
-          if (m_bSortAscending)
+          if (sortAscending)
           {
             iComp = String.Compare(rec1.Channel.Name, rec2.Channel.Name, true);
             if (iComp == 0)
@@ -431,7 +473,7 @@ namespace Mediaportal.TV.TvPlugin
           }
 
         case SortMethod.Date:
-          if (m_bSortAscending)
+          if (sortAscending)
           {
             if (rec1.StartTime == rec2.StartTime)
             {
@@ -636,7 +678,8 @@ namespace Mediaportal.TV.TvPlugin
     private void UpdateButtonStates()
     {
       string strLine = String.Empty;
-      switch (currentSortMethod)
+      SortMethod sortMethod = (btnSeries.Selected ? currentSortMethodSeries : currentSortMethod);
+      switch (sortMethod)
       {
         case SortMethod.Channel:
           strLine = GUILocalizeStrings.Get(620); // Sort by: Channel
@@ -650,7 +693,7 @@ namespace Mediaportal.TV.TvPlugin
       }
 
       GUIControl.SetControlLabel(GetID, btnSortBy.GetID, strLine);
-      btnSortBy.IsAscending = m_bSortAscending;
+      btnSortBy.IsAscending = (btnSeries.Selected ? m_bSortAscendingSeries : m_bSortAscending);
     }
 
     private void SetLabels()
@@ -1219,8 +1262,14 @@ namespace Mediaportal.TV.TvPlugin
 
     private void SortChanged(object sender, SortEventArgs e)
     {
-      m_bSortAscending = e.Order != SortOrder.Descending;
-
+      if (btnSeries.Selected)
+      {
+        m_bSortAscendingSeries = e.Order != SortOrder.Descending;
+      }
+      else
+      {
+        m_bSortAscending = e.Order != SortOrder.Descending;
+      }
       OnSort();
     }
   }
