Index: gtk2_ardour/route_time_axis.cc
===================================================================
--- gtk2_ardour/route_time_axis.cc	(revision 4906)
+++ gtk2_ardour/route_time_axis.cc	(working copy)
@@ -1466,6 +1466,13 @@
 }
 
 
+struct PlaylistSorter {
+    bool operator() (boost::shared_ptr<Playlist> a, boost::shared_ptr<Playlist> b) const {
+        return a->sort_id() < b->sort_id();
+    }
+};
+
+
 void
 RouteTimeAxisView::build_playlist_menu (Gtk::Menu * menu)
 {
@@ -1484,26 +1491,29 @@
 	playlist_menu = new Menu;
 	playlist_menu->set_name ("ArdourContextMenu");
 
-	vector<boost::shared_ptr<Playlist> > playlists;
+	vector<boost::shared_ptr<Playlist> > playlists, playlists_ds;
 	boost::shared_ptr<Diskstream> ds = get_diskstream();
 	RadioMenuItem::Group playlist_group;
 
 	_session.get_playlists (playlists);
 	
+    /* find the playlists for this diskstream */
 	for (vector<boost::shared_ptr<Playlist> >::iterator i = playlists.begin(); i != playlists.end(); ++i) {
-
-		if ((*i)->get_orig_diskstream_id() == ds->id()) {
-			playlist_items.push_back (RadioMenuElem (playlist_group, (*i)->name(), bind (mem_fun (*this, &RouteTimeAxisView::use_playlist),
-												     boost::weak_ptr<Playlist> (*i))));
-
-			if (ds->playlist()->id() == (*i)->id()) {
-				static_cast<RadioMenuItem*>(&playlist_items.back())->set_active();
-			}
-		} else if (ds->playlist()->id() == (*i)->id()) {
-			playlist_items.push_back (RadioMenuElem (playlist_group, (*i)->name(), bind (mem_fun (*this, &RouteTimeAxisView::use_playlist), 
-												     boost::weak_ptr<Playlist>(*i))));
+		if (((*i)->get_orig_diskstream_id() == ds->id()) || (ds->playlist()->id() == (*i)->id())) {
+            playlists_ds.push_back(*i);
+    	}
+	}
+	
+	/* sort the playlists */
+	PlaylistSorter cmp;
+	sort(playlists_ds.begin(), playlists_ds.end(), cmp);
+	
+	/* add the playlists to the menu */
+	for (vector<boost::shared_ptr<Playlist> >::iterator i = playlists_ds.begin(); i != playlists_ds.end(); ++i) {
+		playlist_items.push_back (RadioMenuElem (playlist_group, (*i)->name(), bind (mem_fun (*this, &RouteTimeAxisView::use_playlist),
+											     boost::weak_ptr<Playlist> (*i))));
+		if (ds->playlist()->id() == (*i)->id()) {
 			static_cast<RadioMenuItem*>(&playlist_items.back())->set_active();
-			
 		}
 	}
 
Index: libs/ardour/playlist.cc
===================================================================
--- libs/ardour/playlist.cc	(revision 4906)
+++ libs/ardour/playlist.cc	(working copy)
@@ -26,6 +26,7 @@
 #include <climits>
 
 #include <sigc++/bind.h>
+#include <boost/lexical_cast.hpp>
 
 #include "pbd/failed_constructor.h"
 #include "pbd/stl_delete.h"
@@ -80,7 +81,7 @@
 	init (hide);
 	first_set_state = false;
 	_name = nom;
-	
+	_set_sort_id();
 }
 
 Playlist::Playlist (Session& sess, const XMLNode& node, DataType type, bool hide)
@@ -92,6 +93,7 @@
 
 	init (hide);
 	_name = "unnamed"; /* reset by set_state */
+	_set_sort_id();
 
 	/* set state called by derived class */
 }
@@ -263,6 +265,35 @@
 	/* GoingAway must be emitted by derived classes */
 }
 
+void
+Playlist::_set_sort_id ()
+{
+    /* 
+        Playlists are given names like <track name>.<id> 
+        or <track name>.<edit group name>.<id> where id 
+        is an integer. We extract the id and sort by that.
+    */
+
+    size_t dot_position = _name.find_last_of(".");
+    if (dot_position == string::npos)
+    {
+        _sort_id = 0;
+    }
+    else
+    {
+        string t = _name.substr(dot_position + 1);
+        
+        try
+        {
+            _sort_id = boost::lexical_cast<int>(t);
+        }
+        catch (boost::bad_lexical_cast e)
+        {
+            _sort_id = 0;
+        }
+    }
+}
+
 bool
 Playlist::set_name (const string& str)
 {
@@ -1746,6 +1777,7 @@
 		
 		if (prop->name() == X_("name")) {
 			_name = prop->value();
+        	_set_sort_id();
 		} else if (prop->name() == X_("orig_diskstream_id")) {
 			_orig_diskstream_id = prop->value ();
 		} else if (prop->name() == X_("frozen")) {
Index: libs/ardour/ardour/playlist.h
===================================================================
--- libs/ardour/ardour/playlist.h	(revision 4906)
+++ libs/ardour/ardour/playlist.h	(working copy)
@@ -74,6 +74,7 @@
 	bool used () const { return _refcnt != 0; }
 
 	bool set_name (const string& str);
+	int sort_id() { return _sort_id; }
 
 	const DataType& data_type() const { return _type; }
 
@@ -282,6 +283,9 @@
 	void timestamp_layer_op (boost::shared_ptr<Region>);
 
 	void _split_region (boost::shared_ptr<Region>, nframes_t position);
+	
+	int _sort_id;
+	void _set_sort_id ();
 };
 
 } /* namespace ARDOUR */
