=== modified file 'src/Core/Banshee.Services/Banshee.Sources/PrimarySource.cs'
--- src/Core/Banshee.Services/Banshee.Sources/PrimarySource.cs	2008-11-07 09:08:31 +0000
+++ src/Core/Banshee.Services/Banshee.Sources/PrimarySource.cs	2009-02-02 02:35:53 +0000
@@ -27,6 +27,7 @@
 //
 
 using System;
+using System.Collections;
 using System.Collections.Generic;
 using Mono.Unix;
 
@@ -263,11 +264,13 @@
             // Load our playlists and smart playlists
             foreach (PlaylistSource pl in PlaylistSource.LoadAll (this)) {
                 AddChildSource (pl);
+                pl.Renamed += new SourceRenamedHandler (OnChildRenamed);
             }
 
             int sp_count = 0;
             foreach (SmartPlaylistSource pl in SmartPlaylistSource.LoadAll (this)) {
                 AddChildSource (pl);
+                pl.Renamed += new SourceRenamedHandler (OnChildRenamed);
                 sp_count++;
             }
 
@@ -279,6 +282,7 @@
                         SmartPlaylistSource pl = def.ToSmartPlaylistSource (this);
                         pl.Save ();
                         AddChildSource (pl);
+                        pl.Renamed += new SourceRenamedHandler (OnChildRenamed);
                         pl.RefreshAndReload ();
                         sp_count++;
                     }
@@ -294,6 +298,9 @@
             expanded_schema = new SchemaEntry<bool> (
                 String.Format ("sources.{0}", ParentConfigurationId), "expanded", true, "Is source expanded", "Is source expanded"
             );
+            
+            ResortPlaylists (true);
+            ChildSourceAdded += new SourceEventHandler (OnChildNew);
         }
 
         private bool HaveCreatedSmartPlaylists {
@@ -704,5 +711,34 @@
             DatabaseAlbumInfo.Reset ();
             DatabaseArtistInfo.Reset ();
         }
+        
+        /** Used for re-sorting playlists on load or creation.
+         * 
+         * Orders playlists by name. Manual and smart playlists are mixed together.
+        **/
+        public class PlaylistComparer : IComparer<Source>
+        {
+            static IComparer inner_cmp = new CaseInsensitiveComparer ();
+            public int Compare (Source x, Source y)
+            {
+                return inner_cmp.Compare (x.Name, y.Name);
+            }
+        }
+        
+        protected void ResortPlaylists (bool ascending)
+        {
+            SortChildSources (new PlaylistComparer (), ascending);
+        }
+        
+        protected void OnChildNew (SourceEventArgs args)
+        {
+            ResortPlaylists (true);
+            args.Source.Renamed += new SourceRenamedHandler (OnChildRenamed);
+        }
+        
+        protected void OnChildRenamed (SourceRenamedArgs args)
+        {
+            ResortPlaylists (true);
+        }
     }
 }

=== modified file 'src/Core/Banshee.Services/Banshee.Sources/Source.cs'
--- src/Core/Banshee.Services/Banshee.Sources/Source.cs	2008-11-09 23:25:10 +0000
+++ src/Core/Banshee.Services/Banshee.Sources/Source.cs	2009-02-02 02:23:59 +0000
@@ -58,6 +58,7 @@
         public event EventHandler Updated;
         public event EventHandler UserNotifyUpdated;
         public event EventHandler MessageNotify;
+        public event SourceRenamedHandler Renamed;
         public event SourceEventHandler ChildSourceAdded;
         public event SourceEventHandler ChildSourceRemoved;
 
@@ -146,7 +147,17 @@
 
         public virtual void Rename (string newName)
         {
+            string old_name = Name;
             properties.SetString ("Name", newName);
+            
+            SourceRenamedHandler handler = Renamed;
+            if (handler != null) {
+                SourceRenamedArgs args = new SourceRenamedArgs ();
+                args.Source = this;
+                args.OldName = old_name;
+                args.Name = Name;
+                handler (args);
+            }
         }
         
         public virtual bool AcceptsInputFromSource (Source source)

=== modified file 'src/Core/Banshee.Services/Banshee.Sources/SourceManager.cs'
--- src/Core/Banshee.Services/Banshee.Sources/SourceManager.cs	2008-10-28 00:25:38 +0000
+++ src/Core/Banshee.Services/Banshee.Sources/SourceManager.cs	2009-02-02 02:02:43 +0000
@@ -38,6 +38,7 @@
 {
     public delegate void SourceEventHandler(SourceEventArgs args);
     public delegate void SourceAddedHandler(SourceAddedArgs args);
+    public delegate void SourceRenamedHandler(SourceRenamedArgs args);
     
     public class SourceEventArgs : EventArgs
     {
@@ -49,6 +50,12 @@
         public int Position;
     }
     
+    public class SourceRenamedArgs : SourceEventArgs
+    {
+        public string OldName;
+        public string Name;
+    }
+    
     public class SourceManager : /*ISourceManager,*/ IInitializeService, IRequiredService, IDBusExportable, IDisposable
     {
         private List<Source> sources = new List<Source>();

