Index: mythvideo/mythvideo/videolist.h
===================================================================
--- mythvideo/mythvideo/videolist.h	(revision 9776)
+++ mythvideo/mythvideo/videolist.h	(working copy)
@@ -3,7 +3,6 @@
 
 #include <qapplication.h>
 #include <qdialog.h>
-#include <qmap.h>
 
 #include <mythtv/mythwidgets.h>
 #include <mythtv/uitypes.h>
@@ -21,6 +20,16 @@
 #define ORDER_SUB       1
 #define ORDER_ITEM      2
 
+class SortableMetadataList : public QPtrList<Metadata>
+{
+    public:
+        SortableMetadataList() {};
+        ~SortableMetadataList() {};
+
+    protected:
+        virtual int compareItems(QPtrCollection::Item, QPtrCollection::Item);
+};
+
 class VideoList
 {
     public:
Index: mythvideo/mythvideo/videolist.cpp
===================================================================
--- mythvideo/mythvideo/videolist.cpp	(revision 9776)
+++ mythvideo/mythvideo/videolist.cpp	(working copy)
@@ -6,6 +6,29 @@
 #include <mythtv/mythmedia.h>
 #include <mythtv/mythmediamonitor.h>
 
+int SortableMetadataList::compareItems(QPtrCollection::Item item1,
+                                       QPtrCollection::Item item2) {
+    QRegExp prefixes = QObject::tr("^(The |A |An )");
+    Metadata *meta1 = (Metadata*)item1;
+    Metadata *meta2 = (Metadata*)item2;
+    QString title1 = meta1->Title();
+    QString title2 = meta2->Title();
+
+    // Remove indefinite articles from the title
+    title1.remove(prefixes);
+    title2.remove(prefixes);
+    // Append a secondary sort key for like-named titles
+    title1 += meta1->Filename();
+    title2 += meta2->Filename();
+    // If filenames are identical except for case, we need a tertiary sort key
+    title1 += QString().sprintf("%.7d", meta1->ID());
+    title2 += QString().sprintf("%.7d", meta2->ID());
+    // Make the comparison case-insensitive
+    title1 = title1.lower();
+    title2 = title2.lower();
+    return QString::localeAwareCompare(title1, title2);
+}
+
 VideoList::VideoList(const QString& _prefix)
 {
     currentVideoFilter = new VideoFilterSettings(true, _prefix);
@@ -164,7 +187,7 @@
     //
     //  Accumulate query results into the metaptrs list.
     //
-    QPtrList<Metadata> metaptrs;
+    SortableMetadataList metaptrs;
     while (query.next())
     {
         unsigned int intid = query.value(0).toUInt();
@@ -176,43 +199,16 @@
 
     //
     //  If sorting by title, re-sort by hand because the SQL sort doesn't
-    //  ignore articles when sorting. This assumes all titles are in English.
-    //  This means a movie with a foreign-language title like "A la carte" will
-    //  be incorrectly alphabetized, because the "A" is actually significant.
-    //  The set of ignored prefixes should be a database option, or each
-    //  video's metadata should include a separate sort key.
+    //  ignore articles when sorting. This assumes all titles are in the same
+    //  language.  This means if the locale is set to English, a movie with a
+    //  foreign-language title like "A la carte" will be incorrectly
+    //  alphabetized, because the "A" is actually significant.  The set of
+    //  ignored prefixes should be a database option, or each video's metadata
+    //  should include a separate sort key.
     //
     if (currentVideoFilter->getOrderby() == VideoFilterSettings::kOrderByTitle)
-    {
-        //
-        //  Pull things off the metaptrs list and put them into the
-        //  "stringsort" qmap (which will automatically sort them by qmap key).
-        //
-        QMap<QString, Metadata*> stringsort;
-        QRegExp prefixes = QObject::tr("^(The |A |An )");
-        while (!metaptrs.isEmpty())
-        {
-            Metadata *myData = metaptrs.take(0);
-            QString sTitle = myData->Title();
-            sTitle.remove(prefixes);
+        metaptrs.sort();
 
-            // Append the video ID to allow multiple videos with the same title
-            sTitle += QString().sprintf("%.7d", myData->ID());
-            stringsort[sTitle] = myData;
-        }
-
-        //
-        //  Now walk through the "stringsort" qmap and put them back on the
-        //  list (in stringsort order).
-        //
-        for (QMap<QString, Metadata*>::iterator it = stringsort.begin();
-                it != stringsort.end();
-                it++)
-        {
-            metaptrs.append(*it);
-        }
-    }
-
     //
     //  Build list of videos.
     //
