Skip to content
This repository
Browse code

Merge pull request #2959 from Montellese/sorting_cleanup

cleanup sorting to (almost) get rid of the old SORT_METHOD_FOO
  • Loading branch information...
commit 6edea14c9723738fc87ad9905fb6437304508881 2 parents 66afb93 + 7ec41ee
Sascha Montellese authored August 02, 2013

Showing 59 changed files with 700 additions and 764 deletions. Show diff stats Hide diff stats

  1. 12  xbmc/Autorun.cpp
  2. 105  xbmc/FileItem.cpp
  3. 13  xbmc/FileItem.h
  4. 8  xbmc/GUIInfoManager.cpp
  5. 10  xbmc/SortFileItem.h
  6. 6  xbmc/addons/AddonInstaller.cpp
  7. 2  xbmc/addons/GUIDialogAddonInfo.cpp
  8. 6  xbmc/addons/GUIViewStateAddonBrowser.cpp
  9. 2  xbmc/addons/GUIWindowAddonBrowser.cpp
  10. 2  xbmc/dialogs/GUIDialogFileBrowser.cpp
  11. 2  xbmc/dialogs/GUIDialogMediaFilter.cpp
  12. 2  xbmc/dialogs/GUIDialogSelect.cpp
  13. 2  xbmc/dialogs/GUIDialogSmartPlaylistRule.cpp
  14. 4  xbmc/filesystem/BlurayDirectory.cpp
  15. 14  xbmc/filesystem/HTSPDirectory.cpp
  16. 2  xbmc/filesystem/LibraryDirectory.cpp
  17. 2  xbmc/filesystem/MultiPathDirectory.cpp
  18. 29  xbmc/filesystem/MythDirectory.cpp
  19. 2  xbmc/filesystem/PVRDirectory.cpp
  20. 96  xbmc/filesystem/PluginDirectory.cpp
  21. 1  xbmc/filesystem/PluginDirectory.h
  22. 8  xbmc/filesystem/RSSDirectory.cpp
  23. 2  xbmc/filesystem/RarManager.cpp
  24. 2  xbmc/filesystem/SmartPlaylistDirectory.cpp
  25. 8  xbmc/filesystem/UPnPDirectory.cpp
  26. 12  xbmc/filesystem/test/TestRarFile.cpp
  27. 4  xbmc/input/ButtonTranslator.cpp
  28. 6  xbmc/interfaces/json-rpc/AudioLibrary.cpp
  29. 2  xbmc/interfaces/json-rpc/FileOperations.cpp
  30. 304  xbmc/music/GUIViewStateMusic.cpp
  31. 4  xbmc/music/infoscanner/MusicInfoScanner.cpp
  32. 40  xbmc/network/upnp/UPnPServer.cpp
  33. 20  xbmc/pictures/GUIViewStatePictures.cpp
  34. 15  xbmc/pictures/GUIWindowPictures.cpp
  35. 20  xbmc/pictures/GUIWindowSlideShow.cpp
  36. 17  xbmc/pictures/GUIWindowSlideShow.h
  37. 2  xbmc/pictures/PictureThumbLoader.cpp
  38. 10  xbmc/programs/GUIViewStatePrograms.cpp
  39. 13  xbmc/pvr/windows/GUIViewStatePVR.cpp
  40. 23  xbmc/pvr/windows/GUIWindowPVRCommon.cpp
  41. 3  xbmc/pvr/windows/GUIWindowPVRCommon.h
  42. 4  xbmc/pvr/windows/GUIWindowPVRRecordings.cpp
  43. 2  xbmc/pvr/windows/GUIWindowPVRSearch.cpp
  44. 2  xbmc/pvr/windows/GUIWindowPVRTimers.cpp
  45. 8  xbmc/utils/SortUtils.h
  46. 323  xbmc/video/GUIViewStateVideo.cpp
  47. 6  xbmc/video/VideoDatabase.cpp
  48. 2  xbmc/video/VideoInfoScanner.cpp
  49. 4  xbmc/video/windows/GUIWindowVideoBase.cpp
  50. 8  xbmc/video/windows/GUIWindowVideoNav.cpp
  51. 122  xbmc/view/GUIViewState.cpp
  52. 12  xbmc/view/GUIViewState.h
  53. 57  xbmc/view/ViewDatabase.cpp
  54. 2  xbmc/view/ViewDatabase.h
  55. 14  xbmc/view/ViewState.h
  56. 30  xbmc/view/ViewStateSettings.cpp
  57. 2  xbmc/view/ViewStateSettings.h
  58. 27  xbmc/windows/GUIMediaWindow.cpp
  59. 2  xbmc/windows/GUIWindowFileManager.cpp
12  xbmc/Autorun.cpp
@@ -138,7 +138,7 @@ bool CAutorun::RunDisc(IDirectory* pDir, const CStdString& strDrive, int& nAdded
138 138
   }
139 139
 
140 140
   // Sorting necessary for easier HDDVD handling
141  
-  vecItems.Sort(SORT_METHOD_LABEL, SortOrderAscending);
  141
+  vecItems.Sort(SortByLabel, SortOrderAscending);
142 142
 
143 143
   bool bAllowVideo = true;
144 144
 //  bool bAllowPictures = true;
@@ -220,7 +220,7 @@ bool CAutorun::RunDisc(IDirectory* pDir, const CStdString& strDrive, int& nAdded
220 220
           {
221 221
             // HD DVD Standard says the highest numbered playlist has to be handled first.
222 222
             CLog::Log(LOGINFO,"HD DVD: Playlist found. Set filetypes to *.xpl for external player.");
223  
-            items.Sort(SORT_METHOD_LABEL, SortOrderDescending);
  223
+            items.Sort(SortByLabel, SortOrderDescending);
224 224
             phddvdItem = pItem; 
225 225
             hddvdname = URIUtils::GetFileName(items[0]->GetPath());
226 226
             CLog::Log(LOGINFO,"HD DVD: %s", items[0]->GetPath().c_str());
@@ -240,7 +240,7 @@ bool CAutorun::RunDisc(IDirectory* pDir, const CStdString& strDrive, int& nAdded
240 240
             {
241 241
               // HD DVD Standard says the lowest numbered ifo has to be handled first.
242 242
               CLog::Log(LOGINFO,"HD DVD: IFO found. Set filename to HV* and filetypes to *.ifo for external player.");
243  
-              items.Sort(SORT_METHOD_LABEL, SortOrderAscending);
  243
+              items.Sort(SortByLabel, SortOrderAscending);
244 244
               phddvdItem = pItem; 
245 245
               hddvdname = URIUtils::GetFileName(items[0]->GetPath());
246 246
               CLog::Log(LOGINFO,"HD DVD: %s",items[0]->GetPath().c_str());
@@ -253,7 +253,7 @@ bool CAutorun::RunDisc(IDirectory* pDir, const CStdString& strDrive, int& nAdded
253 253
           if (items.Size())
254 254
           {
255 255
             // Sort *.evo files in alphabetical order.
256  
-            items.Sort(SORT_METHOD_LABEL, SortOrderAscending);
  256
+            items.Sort(SortByLabel, SortOrderAscending);
257 257
             int64_t asize = 0;
258 258
             int ecount = 0;
259 259
             // calculate average size of elements above 1gb
@@ -269,7 +269,7 @@ bool CAutorun::RunDisc(IDirectory* pDir, const CStdString& strDrive, int& nAdded
269 269
               if (items[j]->m_dwSize >= asize)
270 270
                 sitems.Add (items[j]);
271 271
             // Sort *.evo files by size.
272  
-            items.Sort(SORT_METHOD_SIZE, SortOrderDescending);
  272
+            items.Sort(SortBySize, SortOrderDescending);
273 273
             // Add other files with descending size to bottom of new list.
274 274
             for (int j = 0; j < items.Size(); j++)
275 275
               if (items[j]->m_dwSize < asize)
@@ -329,7 +329,7 @@ bool CAutorun::RunDisc(IDirectory* pDir, const CStdString& strDrive, int& nAdded
329 329
           CDirectory::GetDirectory(pItem->GetPath(), items, strExt);
330 330
           if (items.Size())
331 331
           {
332  
-            items.Sort(SORT_METHOD_LABEL, SortOrderAscending);
  332
+            items.Sort(SortByLabel, SortOrderAscending);
333 333
             g_playlistPlayer.ClearPlaylist(PLAYLIST_VIDEO);
334 334
             g_playlistPlayer.Add(PLAYLIST_VIDEO, items);
335 335
             g_playlistPlayer.SetCurrentPlaylist(PLAYLIST_VIDEO);
105  xbmc/FileItem.cpp
@@ -1532,8 +1532,6 @@ CFileItemList::CFileItemList()
1532 1532
   m_fastLookup = false;
1533 1533
   m_bIsFolder = true;
1534 1534
   m_cacheToDisc = CACHE_IF_SLOW;
1535  
-  m_sortMethod = SORT_METHOD_NONE;
1536  
-  m_sortOrder = SortOrderNone;
1537 1535
   m_sortIgnoreFolders = false;
1538 1536
   m_replaceListing = false;
1539 1537
 }
@@ -1542,8 +1540,6 @@ CFileItemList::CFileItemList(const CStdString& strPath) : CFileItem(strPath, tru
1542 1540
 {
1543 1541
   m_fastLookup = false;
1544 1542
   m_cacheToDisc = CACHE_IF_SLOW;
1545  
-  m_sortMethod = SORT_METHOD_NONE;
1546  
-  m_sortOrder = SortOrderNone;
1547 1543
   m_sortIgnoreFolders = false;
1548 1544
   m_replaceListing = false;
1549 1545
 }
@@ -1613,8 +1609,9 @@ void CFileItemList::Clear()
1613 1609
   CSingleLock lock(m_lock);
1614 1610
 
1615 1611
   ClearItems();
1616  
-  m_sortMethod = SORT_METHOD_NONE;
1617  
-  m_sortOrder = SortOrderNone;
  1612
+  m_sortDescription.sortBy = SortByNone;
  1613
+  m_sortDescription.sortOrder = SortOrderNone;
  1614
+  m_sortDescription.sortAttributes = SortAttributeNone;
1618 1615
   m_sortIgnoreFolders = false;
1619 1616
   m_cacheToDisc = CACHE_IF_SLOW;
1620 1617
   m_sortDetails.clear();
@@ -1715,8 +1712,7 @@ void CFileItemList::Assign(const CFileItemList& itemlist, bool append)
1715 1712
   SetPath(itemlist.GetPath());
1716 1713
   SetLabel(itemlist.GetLabel());
1717 1714
   m_sortDetails = itemlist.m_sortDetails;
1718  
-  m_sortMethod = itemlist.m_sortMethod;
1719  
-  m_sortOrder = itemlist.m_sortOrder;
  1715
+  m_sortDescription = itemlist.m_sortDescription;
1720 1716
   m_replaceListing = itemlist.m_replaceListing;
1721 1717
   m_content = itemlist.m_content;
1722 1718
   m_mapProperties = itemlist.m_mapProperties;
@@ -1729,13 +1725,12 @@ bool CFileItemList::Copy(const CFileItemList& items, bool copyItems /* = true */
1729 1725
   *(CFileItem*)this = *(CFileItem*)&items;
1730 1726
 
1731 1727
   // assign the rest of the CFileItemList properties
1732  
-  m_replaceListing = items.m_replaceListing;
1733  
-  m_content        = items.m_content;
1734  
-  m_mapProperties  = items.m_mapProperties;
1735  
-  m_cacheToDisc    = items.m_cacheToDisc;
1736  
-  m_sortDetails    = items.m_sortDetails;
1737  
-  m_sortMethod     = items.m_sortMethod;
1738  
-  m_sortOrder      = items.m_sortOrder;
  1728
+  m_replaceListing  = items.m_replaceListing;
  1729
+  m_content         = items.m_content;
  1730
+  m_mapProperties   = items.m_mapProperties;
  1731
+  m_cacheToDisc     = items.m_cacheToDisc;
  1732
+  m_sortDetails     = items.m_sortDetails;
  1733
+  m_sortDescription = items.m_sortDescription;
1739 1734
   m_sortIgnoreFolders = items.m_sortIgnoreFolders;
1740 1735
 
1741 1736
   if (copyItems)
@@ -1847,26 +1842,24 @@ void CFileItemList::FillSortFields(FILEITEMFILLFUNC func)
1847 1842
   std::for_each(m_items.begin(), m_items.end(), func);
1848 1843
 }
1849 1844
 
1850  
-void CFileItemList::Sort(SORT_METHOD sortMethod, SortOrder sortOrder)
  1845
+void CFileItemList::Sort(SortBy sortBy, SortOrder sortOrder, SortAttribute sortAttributes /* = SortAttributeNone */)
1851 1846
 {
1852  
-  //  Already sorted?
1853  
-  if (sortMethod == m_sortMethod && m_sortOrder == sortOrder)
  1847
+  if (sortBy == SortByNone ||
  1848
+     (m_sortDescription.sortBy == sortBy && m_sortDescription.sortOrder == sortOrder &&
  1849
+      m_sortDescription.sortAttributes == sortAttributes))
1854 1850
     return;
1855 1851
 
1856  
-  SortDescription sorting = SortUtils::TranslateOldSortMethod(sortMethod);
  1852
+  SortDescription sorting;
  1853
+  sorting.sortBy = sortBy;
1857 1854
   sorting.sortOrder = sortOrder;
  1855
+  sorting.sortAttributes = sortAttributes;
1858 1856
 
1859 1857
   Sort(sorting);
1860  
-
1861  
-  m_sortMethod = sortMethod;
1862  
-  m_sortOrder = sortOrder;
  1858
+  m_sortDescription = sorting;
1863 1859
 }
1864 1860
 
1865 1861
 void CFileItemList::Sort(SortDescription sortDescription)
1866 1862
 {
1867  
-  if (sortDescription.sortBy == SortByNone)
1868  
-    return;
1869  
-
1870 1863
   if (sortDescription.sortBy == SortByFile ||
1871 1864
       sortDescription.sortBy == SortBySortTitle ||
1872 1865
       sortDescription.sortBy == SortByDateAdded ||
@@ -1877,6 +1870,11 @@ void CFileItemList::Sort(SortDescription sortDescription)
1877 1870
       sortDescription.sortBy == SortByPlaycount)
1878 1871
     sortDescription.sortAttributes = (SortAttribute)((int)sortDescription.sortAttributes | SortAttributeIgnoreFolders);
1879 1872
 
  1873
+  if (sortDescription.sortBy == SortByNone ||
  1874
+     (m_sortDescription.sortBy == sortDescription.sortBy && m_sortDescription.sortOrder == sortDescription.sortOrder &&
  1875
+      m_sortDescription.sortAttributes == sortDescription.sortAttributes))
  1876
+    return;
  1877
+
1880 1878
   if (m_sortIgnoreFolders)
1881 1879
     sortDescription.sortAttributes = (SortAttribute)((int)sortDescription.sortAttributes | SortAttributeIgnoreFolders);
1882 1880
 
@@ -1927,8 +1925,9 @@ void CFileItemList::Archive(CArchive& ar)
1927 1925
 
1928 1926
     ar << m_fastLookup;
1929 1927
 
1930  
-    ar << (int)m_sortMethod;
1931  
-    ar << (int)m_sortOrder;
  1928
+    ar << (int)m_sortDescription.sortBy;
  1929
+    ar << (int)m_sortDescription.sortOrder;
  1930
+    ar << (int)m_sortDescription.sortAttributes;
1932 1931
     ar << m_sortIgnoreFolders;
1933 1932
     ar << (int)m_cacheToDisc;
1934 1933
 
@@ -1936,7 +1935,9 @@ void CFileItemList::Archive(CArchive& ar)
1936 1935
     for (unsigned int j = 0; j < m_sortDetails.size(); ++j)
1937 1936
     {
1938 1937
       const SORT_METHOD_DETAILS &details = m_sortDetails[j];
1939  
-      ar << (int)details.m_sortMethod;
  1938
+      ar << (int)details.m_sortDescription.sortBy;
  1939
+      ar << (int)details.m_sortDescription.sortOrder;
  1940
+      ar << (int)details.m_sortDescription.sortAttributes;
1940 1941
       ar << details.m_buttonLabel;
1941 1942
       ar << details.m_labelMasks.m_strLabelFile;
1942 1943
       ar << details.m_labelMasks.m_strLabelFolder;
@@ -1986,9 +1987,11 @@ void CFileItemList::Archive(CArchive& ar)
1986 1987
 
1987 1988
     int tempint;
1988 1989
     ar >> (int&)tempint;
1989  
-    m_sortMethod = SORT_METHOD(tempint);
  1990
+    m_sortDescription.sortBy = (SortBy)tempint;
  1991
+    ar >> (int&)tempint;
  1992
+    m_sortDescription.sortOrder = (SortOrder)tempint;
1990 1993
     ar >> (int&)tempint;
1991  
-    m_sortOrder = SortOrder(tempint);
  1994
+    m_sortDescription.sortAttributes = (SortAttribute)tempint;
1992 1995
     ar >> m_sortIgnoreFolders;
1993 1996
     ar >> (int&)tempint;
1994 1997
     m_cacheToDisc = CACHE_TYPE(tempint);
@@ -1999,7 +2002,11 @@ void CFileItemList::Archive(CArchive& ar)
1999 2002
     {
2000 2003
       SORT_METHOD_DETAILS details;
2001 2004
       ar >> (int&)tempint;
2002  
-      details.m_sortMethod = SORT_METHOD(tempint);
  2005
+      details.m_sortDescription.sortBy = (SortBy)tempint;
  2006
+      ar >> (int&)tempint;
  2007
+      details.m_sortDescription.sortOrder = (SortOrder)tempint;
  2008
+      ar >> (int&)tempint;
  2009
+      details.m_sortDescription.sortAttributes = (SortAttribute)tempint;
2003 2010
       ar >> details.m_buttonLabel;
2004 2011
       ar >> details.m_labelMasks.m_strLabelFile;
2005 2012
       ar >> details.m_labelMasks.m_strLabelFolder;
@@ -2245,7 +2252,7 @@ void CFileItemList::Stack(bool stackFiles /* = true */)
2245 2252
   SetProperty("isstacked", true);
2246 2253
 
2247 2254
   // items needs to be sorted for stuff below to work properly
2248  
-  Sort(SORT_METHOD_LABEL, SortOrderAscending);
  2255
+  Sort(SortByLabel, SortOrderAscending);
2249 2256
 
2250 2257
   StackFolders();
2251 2258
 
@@ -2364,7 +2371,7 @@ void CFileItemList::StackFolders()
2364 2371
             item->SetPath(dvdPath);
2365 2372
             item->SetLabel2("");
2366 2373
             item->SetLabelPreformated(true);
2367  
-            m_sortMethod = SORT_METHOD_NONE; /* sorting is now broken */
  2374
+            m_sortDescription.sortBy = SortByNone; /* sorting is now broken */
2368 2375
           }
2369 2376
         }
2370 2377
       }
@@ -2558,7 +2565,8 @@ bool CFileItemList::Load(int windowID)
2558 2565
     CLog::Log(LOGDEBUG,"Loading fileitems [%s]",GetPath().c_str());
2559 2566
     CArchive ar(&file, CArchive::load);
2560 2567
     ar >> *this;
2561  
-    CLog::Log(LOGDEBUG,"  -- items: %i, directory: %s sort method: %i, ascending: %s",Size(),GetPath().c_str(), m_sortMethod, m_sortOrder ? "true" : "false");
  2568
+    CLog::Log(LOGDEBUG,"  -- items: %i, directory: %s sort method: %i, ascending: %s", Size(), GetPath().c_str(), m_sortDescription.sortBy,
  2569
+      m_sortDescription.sortOrder == SortOrderAscending ? "true" : "false");
2562 2570
     ar.Close();
2563 2571
     file.Close();
2564 2572
     return true;
@@ -2580,7 +2588,7 @@ bool CFileItemList::Save(int windowID)
2580 2588
   {
2581 2589
     CArchive ar(&file, CArchive::store);
2582 2590
     ar << *this;
2583  
-    CLog::Log(LOGDEBUG,"  -- items: %i, sort method: %i, ascending: %s",iSize,m_sortMethod, m_sortOrder ? "true" : "false");
  2591
+    CLog::Log(LOGDEBUG,"  -- items: %i, sort method: %i, ascending: %s", iSize, m_sortDescription.sortBy, m_sortDescription.sortOrder == SortOrderAscending ? "true" : "false");
2584 2592
     ar.Close();
2585 2593
     file.Close();
2586 2594
     return true;
@@ -3070,12 +3078,26 @@ bool CFileItemList::UpdateItem(const CFileItem *item)
3070 3078
   return false;
3071 3079
 }
3072 3080
 
3073  
-void CFileItemList::AddSortMethod(SORT_METHOD sortMethod, int buttonLabel, const LABEL_MASKS &labelMasks)
  3081
+void CFileItemList::AddSortMethod(SortBy sortBy, int buttonLabel, const LABEL_MASKS &labelMasks, SortAttribute sortAttributes /* = SortAttributeNone */)
  3082
+{
  3083
+  AddSortMethod(sortBy, sortAttributes, buttonLabel, labelMasks);
  3084
+}
  3085
+
  3086
+void CFileItemList::AddSortMethod(SortBy sortBy, SortAttribute sortAttributes, int buttonLabel, const LABEL_MASKS &labelMasks)
  3087
+{
  3088
+  SortDescription sorting;
  3089
+  sorting.sortBy = sortBy;
  3090
+  sorting.sortAttributes = sortAttributes;
  3091
+
  3092
+  AddSortMethod(sorting, buttonLabel, labelMasks);
  3093
+}
  3094
+
  3095
+void CFileItemList::AddSortMethod(SortDescription sortDescription, int buttonLabel, const LABEL_MASKS &labelMasks)
3074 3096
 {
3075 3097
   SORT_METHOD_DETAILS sort;
3076  
-  sort.m_sortMethod=sortMethod;
3077  
-  sort.m_buttonLabel=buttonLabel;
3078  
-  sort.m_labelMasks=labelMasks;
  3098
+  sort.m_sortDescription = sortDescription;
  3099
+  sort.m_buttonLabel = buttonLabel;
  3100
+  sort.m_labelMasks = labelMasks;
3079 3101
 
3080 3102
   m_sortDetails.push_back(sort);
3081 3103
 }
@@ -3087,8 +3109,9 @@ void CFileItemList::SetReplaceListing(bool replace)
3087 3109
 
3088 3110
 void CFileItemList::ClearSortState()
3089 3111
 {
3090  
-  m_sortMethod = SORT_METHOD_NONE;
3091  
-  m_sortOrder = SortOrderNone;
  3112
+  m_sortDescription.sortBy = SortByNone;
  3113
+  m_sortDescription.sortOrder = SortOrderNone;
  3114
+  m_sortDescription.sortAttributes = SortAttributeNone;
3092 3115
 }
3093 3116
 
3094 3117
 CVideoInfoTag* CFileItem::GetVideoInfoTag()
13  xbmc/FileItem.h
@@ -517,7 +517,7 @@ class CFileItemList : public CFileItem
517 517
   void Assign(const CFileItemList& itemlist, bool append = false);
518 518
   bool Copy  (const CFileItemList& item, bool copyItems = true);
519 519
   void Reserve(int iCount);
520  
-  void Sort(SORT_METHOD sortMethod, SortOrder sortOrder);
  520
+  void Sort(SortBy sortBy, SortOrder sortOrder, SortAttribute sortAttributes = SortAttributeNone);
521 521
   /* \brief Sorts the items based on the given sorting options
522 522
 
523 523
   In contrast to Sort (see above) this does not change the internal
@@ -545,8 +545,8 @@ class CFileItemList : public CFileItem
545 545
    */
546 546
   void Stack(bool stackFiles = true);
547 547
 
548  
-  SortOrder GetSortOrder() const { return m_sortOrder; }
549  
-  SORT_METHOD GetSortMethod() const { return m_sortMethod; }
  548
+  SortOrder GetSortOrder() const { return m_sortDescription.sortOrder; }
  549
+  SortBy GetSortMethod() const { return m_sortDescription.sortBy; }
550 550
   /*! \brief load a CFileItemList out of the cache
551 551
 
552 552
    The file list may be cached based on which window we're viewing in, as different
@@ -593,7 +593,9 @@ class CFileItemList : public CFileItem
593 593
    */
594 594
   bool UpdateItem(const CFileItem *item);
595 595
 
596  
-  void AddSortMethod(SORT_METHOD method, int buttonLabel, const LABEL_MASKS &labelMasks);
  596
+  void AddSortMethod(SortBy sortBy, int buttonLabel, const LABEL_MASKS &labelMasks, SortAttribute sortAttributes = SortAttributeNone);
  597
+  void AddSortMethod(SortBy sortBy, SortAttribute sortAttributes, int buttonLabel, const LABEL_MASKS &labelMasks);
  598
+  void AddSortMethod(SortDescription sortDescription, int buttonLabel, const LABEL_MASKS &labelMasks);
597 599
   bool HasSortDetails() const { return m_sortDetails.size() != 0; };
598 600
   const std::vector<SORT_METHOD_DETAILS> &GetSortDetails() const { return m_sortDetails; };
599 601
 
@@ -630,8 +632,7 @@ class CFileItemList : public CFileItem
630 632
   VECFILEITEMS m_items;
631 633
   MAPFILEITEMS m_map;
632 634
   bool m_fastLookup;
633  
-  SORT_METHOD m_sortMethod;
634  
-  SortOrder m_sortOrder;
  635
+  SortDescription m_sortDescription;
635 636
   bool m_sortIgnoreFolders;
636 637
   CACHE_TYPE m_cacheToDisc;
637 638
   bool m_replaceListing;
8  xbmc/GUIInfoManager.cpp
@@ -1046,10 +1046,8 @@ int CGUIInfoManager::TranslateSingleString(const CStdString &strCondition)
1046 1046
       }
1047 1047
       else if (prop.name == "sort")
1048 1048
       {
1049  
-        SORT_METHOD sort = SORT_METHOD_NONE;
1050  
-        if (prop.param().Equals("songrating")) sort = SORT_METHOD_SONG_RATING;
1051  
-        if (sort != SORT_METHOD_NONE)
1052  
-          return AddMultiInfo(GUIInfo(CONTAINER_SORT_METHOD, sort));
  1049
+        if (prop.param().Equals("songrating"))
  1050
+          return AddMultiInfo(GUIInfo(CONTAINER_SORT_METHOD, SortByRating));
1053 1051
       }
1054 1052
     }
1055 1053
     else if (cat.name == "listitem")
@@ -2867,7 +2865,7 @@ bool CGUIInfoManager::GetMultiInfoBool(const GUIInfo &info, int contextWindow, c
2867 2865
         {
2868 2866
           const CGUIViewState *viewState = ((CGUIMediaWindow*)window)->GetViewState();
2869 2867
           if (viewState)
2870  
-            bReturn = ((unsigned int)viewState->GetSortMethod() == info.GetData1());
  2868
+            bReturn = ((unsigned int)viewState->GetSortMethod().sortBy == info.GetData1());
2871 2869
         }
2872 2870
         break;
2873 2871
       }
10  xbmc/SortFileItem.h
@@ -19,8 +19,6 @@
19 19
  *
20 20
  */
21 21
 
22  
-#include "utils/LabelFormatter.h"
23  
-
24 22
 typedef enum {
25 23
   SORT_METHOD_NONE=0,
26 24
   SORT_METHOD_LABEL,
@@ -65,11 +63,3 @@ typedef enum {
65 63
   SORT_METHOD_DATE_TAKEN,
66 64
   SORT_METHOD_MAX
67 65
 } SORT_METHOD;
68  
-
69  
-typedef struct
70  
-{
71  
-  SORT_METHOD m_sortMethod;
72  
-  int m_buttonLabel;
73  
-  LABEL_MASKS m_labelMasks;
74  
-} SORT_METHOD_DETAILS;
75  
-
6  xbmc/addons/AddonInstaller.cpp
@@ -413,11 +413,11 @@ void CAddonInstaller::PrunePackageCache()
413 413
   for (std::map<CStdString,CFileItemList*>::const_iterator it  = packs.begin();
414 414
                                                           it != packs.end();++it)
415 415
   {
416  
-    it->second->Sort(SORT_METHOD_LABEL,SortOrderDescending);
  416
+    it->second->Sort(SortByLabel, SortOrderDescending);
417 417
     for (int j=2;j<it->second->Size();++j)
418 418
       items.Add(CFileItemPtr(new CFileItem(*it->second->Get(j))));
419 419
   }
420  
-  items.Sort(SORT_METHOD_SIZE,SortOrderDescending);
  420
+  items.Sort(SortBySize, SortOrderDescending);
421 421
   int i=0;
422 422
   while (size > limit && i < items.Size())
423 423
   {
@@ -435,7 +435,7 @@ void CAddonInstaller::PrunePackageCache()
435 435
       if (it->second->Size() > 1)
436 436
         items.Add(CFileItemPtr(new CFileItem(*it->second->Get(1))));
437 437
     }
438  
-    items.Sort(SORT_METHOD_DATE,SortOrderAscending);
  438
+    items.Sort(SortByDate, SortOrderAscending);
439 439
     i=0;
440 440
     while (size > limit && i < items.Size())
441 441
     {
2  xbmc/addons/GUIDialogAddonInfo.cpp
@@ -396,7 +396,7 @@ void CGUIDialogAddonInfo::GrabRollbackVersions()
396 396
 {
397 397
   CFileItemList items;
398 398
   XFILE::CDirectory::GetDirectory("special://home/addons/packages/",items,".zip",DIR_FLAG_NO_FILE_DIRS);
399  
-  items.Sort(SORT_METHOD_LABEL, SortOrderAscending);
  399
+  items.Sort(SortByLabel, SortOrderAscending);
400 400
   for (int i=0;i<items.Size();++i)
401 401
   {
402 402
     if (items[i]->m_bIsFolder)
6  xbmc/addons/GUIViewStateAddonBrowser.cpp
@@ -32,9 +32,9 @@ using namespace ADDON;
32 32
 
33 33
 CGUIViewStateAddonBrowser::CGUIViewStateAddonBrowser(const CFileItemList& items) : CGUIViewState(items)
34 34
 {
35  
-  AddSortMethod(SORT_METHOD_LABEL_IGNORE_FOLDERS, 551, LABEL_MASKS("%L", "%I", "%L", ""));  // Filename, Size | Foldername, empty
36  
-  AddSortMethod(SORT_METHOD_DATE, 552, LABEL_MASKS("%L", "%J", "%L", "%J"));  // Filename, Date | Foldername, Date
37  
-  SetSortMethod(SORT_METHOD_LABEL_IGNORE_FOLDERS);
  35
+  AddSortMethod(SortByLabel, SortAttributeIgnoreFolders, 551, LABEL_MASKS("%L", "%I", "%L", ""));  // Filename, Size | Foldername, empty
  36
+  AddSortMethod(SortByDate, 552, LABEL_MASKS("%L", "%J", "%L", "%J"));  // Filename, Date | Foldername, Date
  37
+  SetSortMethod(SortByLabel, SortAttributeIgnoreFolders);
38 38
 
39 39
   SetViewAsControl(DEFAULT_VIEW_AUTO);
40 40
 
2  xbmc/addons/GUIWindowAddonBrowser.cpp
@@ -448,7 +448,7 @@ int CGUIWindowAddonBrowser::SelectAddonID(const vector<ADDON::TYPE> &types, CStd
448 448
     item->SetSpecialSort(SortSpecialOnTop);
449 449
     items.Add(item);
450 450
   }
451  
-  items.Sort(SORT_METHOD_LABEL, SortOrderAscending);
  451
+  items.Sort(SortByLabel, SortOrderAscending);
452 452
 
453 453
   if (addonIDs.size() > 0)
454 454
   {
2  xbmc/dialogs/GUIDialogFileBrowser.cpp
@@ -334,7 +334,7 @@ void CGUIDialogFileBrowser::ClearFileItems()
334 334
 void CGUIDialogFileBrowser::OnSort()
335 335
 {
336 336
   if (!m_singleList)
337  
-    m_vecItems->Sort(SORT_METHOD_LABEL, SortOrderAscending);
  337
+    m_vecItems->Sort(SortByLabel, SortOrderAscending);
338 338
 }
339 339
 
340 340
 void CGUIDialogFileBrowser::Update(const CStdString &strDirectory)
2  xbmc/dialogs/GUIDialogMediaFilter.cpp
@@ -752,7 +752,7 @@ void CGUIDialogMediaFilter::OnBrowse(const Filter &filter, CFileItemList &items,
752 752
   }
753 753
 
754 754
   // sort the items
755  
-  selectItems.Sort(SORT_METHOD_LABEL, SortOrderAscending);
  755
+  selectItems.Sort(SortByLabel, SortOrderAscending);
756 756
 
757 757
   CGUIDialogSelect* pDialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT);
758 758
   pDialog->Reset();
2  xbmc/dialogs/GUIDialogSelect.cpp
@@ -228,7 +228,7 @@ bool CGUIDialogSelect::IsButtonPressed()
228 228
 
229 229
 void CGUIDialogSelect::Sort(bool bSortOrder /*=true*/)
230 230
 {
231  
-  m_vecList->Sort(SORT_METHOD_LABEL, bSortOrder ? SortOrderAscending : SortOrderDescending);
  231
+  m_vecList->Sort(SortByLabel, bSortOrder ? SortOrderAscending : SortOrderDescending);
232 232
 }
233 233
 
234 234
 void CGUIDialogSelect::SetSelected(int iSelected)
2  xbmc/dialogs/GUIDialogSmartPlaylistRule.cpp
@@ -308,7 +308,7 @@ void CGUIDialogSmartPlaylistRule::OnBrowse()
308 308
   }
309 309
 
310 310
   // sort the items
311  
-  items.Sort(SORT_METHOD_LABEL, SortOrderAscending);
  311
+  items.Sort(SortByLabel, SortOrderAscending);
312 312
 
313 313
   CGUIDialogSelect* pDialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT);
314 314
   pDialog->Reset();
4  xbmc/filesystem/BlurayDirectory.cpp
@@ -174,8 +174,8 @@ bool CBlurayDirectory::GetDirectory(const CStdString& path, CFileItemList &items
174 174
   else
175 175
     return false;
176 176
 
177  
-  items.AddSortMethod(SORT_METHOD_TRACKNUM , 554, LABEL_MASKS("%L", "%D", "%L", ""));    // FileName, Duration | Foldername, empty
178  
-  items.AddSortMethod(SORT_METHOD_SIZE     , 553, LABEL_MASKS("%L", "%I", "%L", "%I"));  // FileName, Size | Foldername, Size
  177
+  items.AddSortMethod(SortByTrackNumber,  554, LABEL_MASKS("%L", "%D", "%L", ""));    // FileName, Duration | Foldername, empty
  178
+  items.AddSortMethod(SortBySize,         553, LABEL_MASKS("%L", "%I", "%L", "%I"));  // FileName, Size | Foldername, Size
179 179
 
180 180
   return true;
181 181
 }
14  xbmc/filesystem/HTSPDirectory.cpp
@@ -389,17 +389,9 @@ bool CHTSPDirectory::GetChannels( const CURL &base
389 389
     items.Add(item);
390 390
   }
391 391
 
392  
-  items.AddSortMethod(SORT_METHOD_TRACKNUM, 554, LABEL_MASKS("%K[ - %B]", "%Z", "%L", ""));
393  
-
394  
-  if (CSettings::Get().GetBool("filelists.ignorethewhensorting"))
395  
-    items.AddSortMethod(SORT_METHOD_ALBUM_IGNORE_THE, 558,   LABEL_MASKS("%B", "%Z", "%L", ""));
396  
-  else
397  
-    items.AddSortMethod(SORT_METHOD_ALBUM,            558,   LABEL_MASKS("%B", "%Z", "%L", ""));
398  
-
399  
-  if (CSettings::Get().GetBool("filelists.ignorethewhensorting"))
400  
-    items.AddSortMethod(SORT_METHOD_LABEL_IGNORE_THE, 551, LABEL_MASKS("%Z", "%B", "%L", ""));
401  
-  else
402  
-    items.AddSortMethod(SORT_METHOD_LABEL,            551, LABEL_MASKS("%Z", "%B", "%L", ""));
  392
+  items.AddSortMethod(SortByTrackNumber,   554, LABEL_MASKS("%K[ - %B]", "%Z", "%L", ""));
  393
+  items.AddSortMethod(SortByAlbum,         558, LABEL_MASKS("%B", "%Z", "%L", ""), CSettings::Get().GetBool("filelists.ignorethewhensorting") ? SortAttributeIgnoreArticle : SortAttributeNone);
  394
+  items.AddSortMethod(SortByLabel,         551, LABEL_MASKS("%Z", "%B", "%L", ""), CSettings::Get().GetBool("filelists.ignorethewhensorting") ? SortAttributeIgnoreArticle : SortAttributeNone);
403 395
 
404 396
   items.SetContent("livetv");
405 397
 
2  xbmc/filesystem/LibraryDirectory.cpp
@@ -140,7 +140,7 @@ bool CLibraryDirectory::GetDirectory(const CStdString& strPath, CFileItemList &i
140 140
       items.Add(item);
141 141
     }
142 142
   }
143  
-  items.Sort(SORT_METHOD_PLAYLIST_ORDER, SortOrderAscending);
  143
+  items.Sort(SortByPlaylistOrder, SortOrderAscending);
144 144
   return true;
145 145
 }
146 146
 
2  xbmc/filesystem/MultiPathDirectory.cpp
@@ -260,7 +260,7 @@ void CMultiPathDirectory::MergeItems(CFileItemList &items)
260 260
     return;
261 261
   // sort items by label
262 262
   // folders are before files in this sort method
263  
-  items.Sort(SORT_METHOD_LABEL, SortOrderAscending);
  263
+  items.Sort(SortByLabel, SortOrderAscending);
264 264
   int i = 0;
265 265
 
266 266
   // if first item in the sorted list is a file, just abort
29  xbmc/filesystem/MythDirectory.cpp
@@ -150,7 +150,7 @@ bool CMythDirectory::GetGuide(const CStdString& base, CFileItemList &items)
150 150
     }
151 151
   }
152 152
 
153  
-  items.AddSortMethod(SORT_METHOD_LABEL, 551 /* Name */, LABEL_MASKS("", "", "%K", ""));
  153
+  items.AddSortMethod(SortByLabel, 551 /* Name */, LABEL_MASKS("", "", "%K", ""));
154 154
 
155 155
   m_dll->ref_release(list);
156 156
   return true;
@@ -227,7 +227,7 @@ bool CMythDirectory::GetGuideForChannel(const CStdString& base, CFileItemList &i
227 227
    * result in the guide being shown in the wrong order for skins that sort by date in descending
228 228
    * order by default with no option to change to ascending, e.g. Confluence.
229 229
    */
230  
-  items.AddSortMethod(SORT_METHOD_NONE, 552 /* Date */, LABEL_MASKS("%K", "%J")); // Still leave the date label
  230
+  items.AddSortMethod(SortByNone, 552 /* Date */, LABEL_MASKS("%K", "%J")); // Still leave the date label
231 231
 
232 232
   m_dll->ref_release(program);
233 233
   return true;
@@ -325,13 +325,8 @@ bool CMythDirectory::GetRecordings(const CStdString& base, CFileItemList &items,
325 325
    * the subtitle doesn't influence the sort order and they are sorted by date.
326 326
    */
327 327
   if (type != TV_SHOWS)
328  
-  {
329  
-    if (CSettings::Get().GetBool("filelists.ignorethewhensorting"))
330  
-      items.AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE_IGNORE_THE, 556, LABEL_MASKS("%K", "%J"));
331  
-    else
332  
-      items.AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE, 556, LABEL_MASKS("%K", "%J"));
333  
-  }
334  
-  items.AddSortMethod(SORT_METHOD_DATE, 552 /* Date */, LABEL_MASKS("%K", "%J"));
  328
+    items.AddSortMethod(SortBySortTitle, 556 /* Name */, LABEL_MASKS("%K", "%J"), CSettings::Get().GetBool("filelists.ignorethewhensorting") ? SortAttributeIgnoreArticle : SortAttributeNone);
  329
+  items.AddSortMethod(SortByDate, 552 /* Date */, LABEL_MASKS("%K", "%J"));
335 330
 
336 331
   return true;
337 332
 }
@@ -392,11 +387,8 @@ bool CMythDirectory::GetTvShowFolders(const CStdString& base, CFileItemList &ite
392 387
   }
393 388
   m_dll->ref_release(list);
394 389
 
395  
-  if (CSettings::Get().GetBool("filelists.ignorethewhensorting"))
396  
-    items.AddSortMethod(SORT_METHOD_LABEL_IGNORE_THE, 551 /* Name */, LABEL_MASKS("", "", "%L", "%J"));
397  
-  else
398  
-    items.AddSortMethod(SORT_METHOD_LABEL, 551 /* Name */, LABEL_MASKS("", "", "%L", "%J"));
399  
-  items.AddSortMethod(SORT_METHOD_DATE, 552 /* Date */, LABEL_MASKS("", "", "%L", "%J"));
  390
+  items.AddSortMethod(SortByLabel, 551 /* Name */, LABEL_MASKS("", "", "%L", "%J"), CSettings::Get().GetBool("filelists.ignorethewhensorting") ? SortAttributeIgnoreArticle : SortAttributeNone);
  391
+  items.AddSortMethod(SortByDate, 552 /* Date */, LABEL_MASKS("", "", "%L", "%J"));
400 392
 
401 393
   return true;
402 394
 }
@@ -464,15 +456,12 @@ bool CMythDirectory::GetChannels(const CStdString& base, CFileItemList &items)
464 456
     m_dll->ref_release(program);
465 457
   }
466 458
 
467  
-  items.AddSortMethod(SORT_METHOD_LABEL, 551 /* Name */, LABEL_MASKS("%K", "%B"));
  459
+  items.AddSortMethod(SortByLabel, 551 /* Name */, LABEL_MASKS("%K", "%B"));
468 460
 
469 461
   /*
470 462
    * Video sort title is set to the channel number.
471 463
    */
472  
-  if (CSettings::Get().GetBool("filelists.ignorethewhensorting"))
473  
-    items.AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE_IGNORE_THE, 556 /* Title */, LABEL_MASKS("%K", "%B"));
474  
-  else
475  
-    items.AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE, 556 /* Title */, LABEL_MASKS("%K", "%B"));
  464
+  items.AddSortMethod(SortBySortTitle, 556 /* Title */, LABEL_MASKS("%K", "%B"), CSettings::Get().GetBool("filelists.ignorethewhensorting") ? SortAttributeIgnoreArticle : SortAttributeNone);
476 465
 
477 466
   return true;
478 467
 }
@@ -528,7 +517,7 @@ bool CMythDirectory::GetDirectory(const CStdString& strPath, CFileItemList &item
528 517
     item->SetLabel(g_localizeStrings.Get(22020)); // Guide
529 518
     items.Add(item);
530 519
 
531  
-    items.AddSortMethod(SORT_METHOD_NONE, 564 /* Type */, LABEL_MASKS("", "", "%L", "")); // No sorting, as added to list.
  520
+    items.AddSortMethod(SortByNone, 564 /* Type */, LABEL_MASKS("", "", "%L", "")); // No sorting, as added to list.
532 521
 
533 522
     /*
534 523
      * Clear the directory cache so the cached sub-folders are guaranteed to be accurate.
2  xbmc/filesystem/PVRDirectory.cpp
@@ -92,7 +92,7 @@ bool CPVRDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items
92 92
     items.Add(item);
93 93
 
94 94
     // Sort by name only. Labels are preformated.
95  
-    items.AddSortMethod(SORT_METHOD_LABEL, 551 /* Name */, LABEL_MASKS("%L", "", "%L", ""));
  95
+    items.AddSortMethod(SortByLabel, 551 /* Name */, LABEL_MASKS("%L", "", "%L", ""));
96 96
 
97 97
     return true;
98 98
   }
96  xbmc/filesystem/PluginDirectory.cpp
@@ -209,7 +209,7 @@ void CPluginDirectory::EndOfDirectory(int handle, bool success, bool replaceList
209 209
   dir->m_listItems->SetReplaceListing(replaceListing);
210 210
 
211 211
   if (!dir->m_listItems->HasSortDetails())
212  
-    dir->m_listItems->AddSortMethod(SORT_METHOD_NONE, 552, LABEL_MASKS("%L", "%D"));
  212
+    dir->m_listItems->AddSortMethod(SortByNone, 552, LABEL_MASKS("%L", "%D"));
213 213
 
214 214
   // set the event to mark that we're done
215 215
   dir->m_fetchComplete.Set();
@@ -228,145 +228,119 @@ void CPluginDirectory::AddSortMethod(int handle, SORT_METHOD sortMethod, const C
228 228
     case SORT_METHOD_LABEL:
229 229
     case SORT_METHOD_LABEL_IGNORE_THE:
230 230
       {
231  
-        if (CSettings::Get().GetBool("filelists.ignorethewhensorting"))
232  
-          dir->m_listItems->AddSortMethod(SORT_METHOD_LABEL_IGNORE_THE, 551, LABEL_MASKS("%T", label2Mask));
233  
-        else
234  
-          dir->m_listItems->AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS("%T", label2Mask));
  231
+        dir->m_listItems->AddSortMethod(SortByLabel, 551, LABEL_MASKS("%T", label2Mask), CSettings::Get().GetBool("filelists.ignorethewhensorting") ? SortAttributeIgnoreArticle : SortAttributeNone);
235 232
         break;
236 233
       }
237 234
     case SORT_METHOD_TITLE:
238 235
     case SORT_METHOD_TITLE_IGNORE_THE:
239 236
       {
240  
-        if (CSettings::Get().GetBool("filelists.ignorethewhensorting"))
241  
-          dir->m_listItems->AddSortMethod(SORT_METHOD_TITLE_IGNORE_THE, 556, LABEL_MASKS("%T", label2Mask));
242  
-        else
243  
-          dir->m_listItems->AddSortMethod(SORT_METHOD_TITLE, 556, LABEL_MASKS("%T", label2Mask));
  237
+        dir->m_listItems->AddSortMethod(SortByTitle, 556, LABEL_MASKS("%T", label2Mask), CSettings::Get().GetBool("filelists.ignorethewhensorting") ? SortAttributeIgnoreArticle : SortAttributeNone);
244 238
         break;
245 239
       }
246 240
     case SORT_METHOD_ARTIST:
247 241
     case SORT_METHOD_ARTIST_IGNORE_THE:
248 242
       {
249  
-        if (CSettings::Get().GetBool("filelists.ignorethewhensorting"))
250  
-          dir->m_listItems->AddSortMethod(SORT_METHOD_ARTIST_IGNORE_THE, 557, LABEL_MASKS("%T", "%A"));
251  
-        else
252  
-          dir->m_listItems->AddSortMethod(SORT_METHOD_ARTIST, 557, LABEL_MASKS("%T", "%A"));
  243
+        dir->m_listItems->AddSortMethod(SortByArtist, 557, LABEL_MASKS("%T", "%A"), CSettings::Get().GetBool("filelists.ignorethewhensorting") ? SortAttributeIgnoreArticle : SortAttributeNone);
253 244
         break;
254 245
       }
255 246
     case SORT_METHOD_ALBUM:
256 247
     case SORT_METHOD_ALBUM_IGNORE_THE:
257 248
       {
258  
-        if (CSettings::Get().GetBool("filelists.ignorethewhensorting"))
259  
-          dir->m_listItems->AddSortMethod(SORT_METHOD_ALBUM_IGNORE_THE, 558, LABEL_MASKS("%T", "%B"));
260  
-        else
261  
-          dir->m_listItems->AddSortMethod(SORT_METHOD_ALBUM, 558, LABEL_MASKS("%T", "%B"));
  249
+        dir->m_listItems->AddSortMethod(SortByAlbum, 558, LABEL_MASKS("%T", "%B"), CSettings::Get().GetBool("filelists.ignorethewhensorting") ? SortAttributeIgnoreArticle : SortAttributeNone);
262 250
         break;
263 251
       }
264 252
     case SORT_METHOD_DATE:
265 253
       {
266  
-        dir->m_listItems->AddSortMethod(SORT_METHOD_DATE, 552, LABEL_MASKS("%T", "%J"));
  254
+        dir->m_listItems->AddSortMethod(SortByDate, 552, LABEL_MASKS("%T", "%J"));
267 255
         break;
268 256
       }
269 257
     case SORT_METHOD_BITRATE:
270 258
       {
271  
-        dir->m_listItems->AddSortMethod(SORT_METHOD_BITRATE, 623, LABEL_MASKS("%T", "%X"));
  259
+        dir->m_listItems->AddSortMethod(SortByBitrate, 623, LABEL_MASKS("%T", "%X"));
272 260
         break;
273 261
       }             
274 262
     case SORT_METHOD_SIZE:
275 263
       {
276  
-        dir->m_listItems->AddSortMethod(SORT_METHOD_SIZE, 553, LABEL_MASKS("%T", "%I"));
  264
+        dir->m_listItems->AddSortMethod(SortBySize, 553, LABEL_MASKS("%T", "%I"));
277 265
         break;
278 266
       }
279 267
     case SORT_METHOD_FILE:
280 268
       {
281  
-        dir->m_listItems->AddSortMethod(SORT_METHOD_FILE, 561, LABEL_MASKS("%T", label2Mask));
  269
+        dir->m_listItems->AddSortMethod(SortByFile, 561, LABEL_MASKS("%T", label2Mask));
282 270
         break;
283 271
       }
284 272
     case SORT_METHOD_TRACKNUM:
285 273
       {
286  
-        dir->m_listItems->AddSortMethod(SORT_METHOD_TRACKNUM, 554, LABEL_MASKS("[%N. ]%T", label2Mask));
  274
+        dir->m_listItems->AddSortMethod(SortByTrackNumber, 554, LABEL_MASKS("[%N. ]%T", label2Mask));
287 275
         break;
288 276
       }
289 277
     case SORT_METHOD_DURATION:
  278
+    case SORT_METHOD_VIDEO_RUNTIME:
290 279
       {
291  
-        dir->m_listItems->AddSortMethod(SORT_METHOD_DURATION, 180, LABEL_MASKS("%T", "%D"));
  280
+        dir->m_listItems->AddSortMethod(SortByTime, 180, LABEL_MASKS("%T", "%D"));
292 281
         break;
293 282
       }
294 283
     case SORT_METHOD_VIDEO_RATING:
  284
+    case SORT_METHOD_SONG_RATING:
295 285
       {
296  
-        dir->m_listItems->AddSortMethod(SORT_METHOD_VIDEO_RATING, 563, LABEL_MASKS("%T", "%R"));
  286
+        dir->m_listItems->AddSortMethod(SortByRating, 563, LABEL_MASKS("%T", "%R"));
297 287
         break;
298 288
       }
299 289
     case SORT_METHOD_YEAR:
300 290
       {
301  
-        dir->m_listItems->AddSortMethod(SORT_METHOD_YEAR, 562, LABEL_MASKS("%T", "%Y"));
302  
-        break;
303  
-      }
304  
-    case SORT_METHOD_SONG_RATING:
305  
-      {
306  
-        dir->m_listItems->AddSortMethod(SORT_METHOD_SONG_RATING, 563, LABEL_MASKS("%T", "%R"));
  291
+        dir->m_listItems->AddSortMethod(SortByYear, 562, LABEL_MASKS("%T", "%Y"));
307 292
         break;
308 293
       }
309 294
     case SORT_METHOD_GENRE:
310 295
       {
311  
-        dir->m_listItems->AddSortMethod(SORT_METHOD_GENRE, 515, LABEL_MASKS("%T", "%G"));
  296
+        dir->m_listItems->AddSortMethod(SortByGenre, 515, LABEL_MASKS("%T", "%G"));
312 297
         break;
313 298
       }
314 299
     case SORT_METHOD_COUNTRY:
315 300
       {
316  
-        dir->m_listItems->AddSortMethod(SORT_METHOD_COUNTRY, 574, LABEL_MASKS("%T", "%G"));
  301
+        dir->m_listItems->AddSortMethod(SortByCountry, 574, LABEL_MASKS("%T", "%G"));
317 302
         break;
318 303
       }
319 304
     case SORT_METHOD_VIDEO_TITLE:
320 305
       {
321  
-        dir->m_listItems->AddSortMethod(SORT_METHOD_VIDEO_TITLE, 369, LABEL_MASKS("%T", label2Mask));
  306
+        dir->m_listItems->AddSortMethod(SortByTitle, 369, LABEL_MASKS("%T", label2Mask));
322 307
         break;
323 308
       }
324 309
     case SORT_METHOD_VIDEO_SORT_TITLE:
325 310
     case SORT_METHOD_VIDEO_SORT_TITLE_IGNORE_THE:
326 311
       {
327  
-        if (CSettings::Get().GetBool("filelists.ignorethewhensorting"))
328  
-          dir->m_listItems->AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE_IGNORE_THE, 556, LABEL_MASKS("%T", label2Mask));
329  
-        else
330  
-          dir->m_listItems->AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE, 556, LABEL_MASKS("%T", label2Mask));
  312
+        dir->m_listItems->AddSortMethod(SortBySortTitle, 556, LABEL_MASKS("%T", label2Mask), CSettings::Get().GetBool("filelists.ignorethewhensorting") ? SortAttributeIgnoreArticle : SortAttributeNone);
331 313
         break;
332 314
       }
333 315
     case SORT_METHOD_MPAA_RATING:
334 316
       {
335  
-        dir->m_listItems->AddSortMethod(SORT_METHOD_MPAA_RATING, 20074, LABEL_MASKS("%T", "%O"));
336  
-        break;
337  
-      }
338  
-    case SORT_METHOD_VIDEO_RUNTIME:
339  
-      {
340  
-        dir->m_listItems->AddSortMethod(SORT_METHOD_VIDEO_RUNTIME, 180, LABEL_MASKS("%T", "%D"));
  317
+        dir->m_listItems->AddSortMethod(SortByMPAA, 20074, LABEL_MASKS("%T", "%O"));
341 318
         break;
342 319
       }
343 320
     case SORT_METHOD_STUDIO:
344 321
     case SORT_METHOD_STUDIO_IGNORE_THE:
345 322
       {
346  
-        if (CSettings::Get().GetBool("filelists.ignorethewhensorting"))
347  
-          dir->m_listItems->AddSortMethod(SORT_METHOD_STUDIO_IGNORE_THE, 572, LABEL_MASKS("%T", "%U"));
348  
-        else
349  
-          dir->m_listItems->AddSortMethod(SORT_METHOD_STUDIO, 572, LABEL_MASKS("%T", "%U"));
  323
+        dir->m_listItems->AddSortMethod(SortByStudio, 572, LABEL_MASKS("%T", "%U"), CSettings::Get().GetBool("filelists.ignorethewhensorting") ? SortAttributeIgnoreArticle : SortAttributeNone);
350 324
         break;
351 325
       }
352 326
     case SORT_METHOD_PROGRAM_COUNT:
353 327
       {
354  
-        dir->m_listItems->AddSortMethod(SORT_METHOD_PROGRAM_COUNT, 567, LABEL_MASKS("%T", "%C"));
  328
+        dir->m_listItems->AddSortMethod(SortByProgramCount, 567, LABEL_MASKS("%T", "%C"));
355 329
         break;
356 330
       }
357 331
     case SORT_METHOD_UNSORTED:
358 332
       {
359  
-        dir->m_listItems->AddSortMethod(SORT_METHOD_UNSORTED, 571, LABEL_MASKS("%T", label2Mask));
  333
+        dir->m_listItems->AddSortMethod(SortByNone, 571, LABEL_MASKS("%T", label2Mask));
360 334
         break;
361 335
       }
362 336
     case SORT_METHOD_NONE:
363 337
       {
364  
-        dir->m_listItems->AddSortMethod(SORT_METHOD_NONE, 552, LABEL_MASKS("%T", label2Mask));
  338
+        dir->m_listItems->AddSortMethod(SortByNone, 552, LABEL_MASKS("%T", label2Mask));
365 339
         break;
366 340
       }
367 341
     case SORT_METHOD_DRIVE_TYPE:
368 342
       {
369  
-        dir->m_listItems->AddSortMethod(SORT_METHOD_DRIVE_TYPE, 564, LABEL_MASKS()); // Preformatted
  343
+        dir->m_listItems->AddSortMethod(SortByDriveType, 564, LABEL_MASKS()); // Preformatted
370 344
         break;
371 345
       }
372 346
     case SORT_METHOD_PLAYLIST_ORDER:
@@ -374,53 +348,53 @@ void CPluginDirectory::AddSortMethod(int handle, SORT_METHOD sortMethod, const C
374 348
         CStdString strTrackLeft=CSettings::Get().GetString("musicfiles.trackformat");
375 349
         CStdString strTrackRight=CSettings::Get().GetString("musicfiles.trackformatright");
376 350
 
377  
-        dir->m_listItems->AddSortMethod(SORT_METHOD_PLAYLIST_ORDER, 559, LABEL_MASKS(strTrackLeft, strTrackRight));
  351
+        dir->m_listItems->AddSortMethod(SortByPlaylistOrder, 559, LABEL_MASKS(strTrackLeft, strTrackRight));
378 352
         break;
379 353
       }
380 354
     case SORT_METHOD_EPISODE:
381 355
       {
382  
-        dir->m_listItems->AddSortMethod(SORT_METHOD_EPISODE,20359,LABEL_MASKS("%E. %T","%R"));
  356
+        dir->m_listItems->AddSortMethod(SortByEpisodeNumber, 20359, LABEL_MASKS("%E. %T","%R"));
383 357
         break;
384 358
       }
385 359
     case SORT_METHOD_PRODUCTIONCODE:
386 360
       {
387 361
         //dir->m_listItems.AddSortMethod(SORT_METHOD_PRODUCTIONCODE,20368,LABEL_MASKS("%E. %T","%P", "%E. %T","%P"));
388  
-        dir->m_listItems->AddSortMethod(SORT_METHOD_PRODUCTIONCODE,20368,LABEL_MASKS("%H. %T","%P", "%H. %T","%P"));
  362
+        dir->m_listItems->AddSortMethod(SortByProductionCode, 20368, LABEL_MASKS("%H. %T","%P", "%H. %T","%P"));
389 363
         break;
390 364
       }
391 365
     case SORT_METHOD_LISTENERS:
392 366
       {
393  
-       dir->m_listItems->AddSortMethod(SORT_METHOD_LISTENERS,20455,LABEL_MASKS("%T","%W"));
  367
+       dir->m_listItems->AddSortMethod(SortByListeners, 20455, LABEL_MASKS("%T","%W"));
394 368
        break;
395 369
       }
396 370
     case SORT_METHOD_DATEADDED:
397 371
       {
398  
-        dir->m_listItems->AddSortMethod(SORT_METHOD_DATEADDED, 570, LABEL_MASKS("%T", "%a"));
  372
+        dir->m_listItems->AddSortMethod(SortByDateAdded, 570, LABEL_MASKS("%T", "%a"));
399 373
         break;
400 374
       }
401 375
     case SORT_METHOD_FULLPATH:
402 376
       {
403  
-        dir->m_listItems->AddSortMethod(SORT_METHOD_FULLPATH, 573, LABEL_MASKS("%T", label2Mask));
  377
+        dir->m_listItems->AddSortMethod(SortByPath, 573, LABEL_MASKS("%T", label2Mask));
404 378
         break;
405 379
       }
406 380
     case SORT_METHOD_LABEL_IGNORE_FOLDERS:
407 381
       {
408  
-        dir->m_listItems->AddSortMethod(SORT_METHOD_LABEL_IGNORE_FOLDERS, 551, LABEL_MASKS("%T", label2Mask));
  382
+        dir->m_listItems->AddSortMethod(SortByLabel, SortAttributeIgnoreFolders, 551, LABEL_MASKS("%T", label2Mask));
409 383
         break;
410 384
       }
411 385
     case SORT_METHOD_LASTPLAYED:
412 386
       {
413  
-        dir->m_listItems->AddSortMethod(SORT_METHOD_LASTPLAYED, 568, LABEL_MASKS("%T", "%G"));
  387
+        dir->m_listItems->AddSortMethod(SortByLastPlayed, 568, LABEL_MASKS("%T", "%G"));
414 388
         break;
415 389
       }
416 390
     case SORT_METHOD_PLAYCOUNT:
417 391
       {
418  
-        dir->m_listItems->AddSortMethod(SORT_METHOD_PLAYCOUNT, 567, LABEL_MASKS("%T", "%V"));
  392
+        dir->m_listItems->AddSortMethod(SortByPlaycount, 567, LABEL_MASKS("%T", "%V"));
419 393
         break;
420 394
       }
421 395
     case SORT_METHOD_CHANNEL:
422 396
       {
423  
-        dir->m_listItems->AddSortMethod(SORT_METHOD_CHANNEL, 19029, LABEL_MASKS("%T", label2Mask));
  397
+        dir->m_listItems->AddSortMethod(SortByChannel, 19029, LABEL_MASKS("%T", label2Mask));
424 398
         break;
425 399
       }
426 400
    
1  xbmc/filesystem/PluginDirectory.h
@@ -33,6 +33,7 @@
33 33
 #include "threads/Event.h"
34 34
 
35 35
 class CURL;
  36
+class CFileItem;
36 37
 class CFileItemList;
37 38
 
38 39
 namespace XFILE
8  xbmc/filesystem/RSSDirectory.cpp
@@ -613,10 +613,10 @@ bool CRSSDirectory::GetDirectory(const CStdString& path, CFileItemList &items)
613 613
       items.Add(item);
614 614
   }
615 615
 
616  
-  items.AddSortMethod(SORT_METHOD_UNSORTED , 231, LABEL_MASKS("%L", "%D", "%L", ""));    // FileName, Duration | Foldername, empty
617  
-  items.AddSortMethod(SORT_METHOD_LABEL    , 551, LABEL_MASKS("%L", "%D", "%L", ""));    // FileName, Duration | Foldername, empty
618  
-  items.AddSortMethod(SORT_METHOD_SIZE     , 553, LABEL_MASKS("%L", "%I", "%L", "%I"));  // FileName, Size | Foldername, Size
619  
-  items.AddSortMethod(SORT_METHOD_DATE     , 552, LABEL_MASKS("%L", "%J", "%L", "%J"));  // FileName, Date | Foldername, Date
  616
+  items.AddSortMethod(SortByNone   , 231, LABEL_MASKS("%L", "%D", "%L", ""));    // FileName, Duration | Foldername, empty
  617
+  items.AddSortMethod(SortByLabel  , 551, LABEL_MASKS("%L", "%D", "%L", ""));    // FileName, Duration | Foldername, empty
  618
+  items.AddSortMethod(SortBySize   , 553, LABEL_MASKS("%L", "%I", "%L", "%I"));  // FileName, Size | Foldername, Size
  619
+  items.AddSortMethod(SortByDate   , 552, LABEL_MASKS("%L", "%J", "%L", "%J"));  // FileName, Date | Foldername, Date
620 620
 
621 621
   CDateTime time = CDateTime::GetCurrentDateTime();
622 622
   int mins = 60;
2  xbmc/filesystem/RarManager.cpp
@@ -117,7 +117,7 @@ bool CRarManager::CacheRarredFile(CStdString& strPathInCache, const CStdString&
117 117
     {
118 118
       CFileItemList items;
119 119
       CDirectory::GetDirectory(g_advancedSettings.m_cachePath,items);
120  
-      items.Sort(SORT_METHOD_SIZE, SortOrderDescending);
  120
+      items.Sort(SortBySize, SortOrderDescending);
121 121
       while (items.Size() && CheckFreeSpace(strDir) < iSize)
122 122
       {
123 123
         if (!items[0]->m_bIsFolder)
2  xbmc/filesystem/SmartPlaylistDirectory.cpp
@@ -287,7 +287,7 @@ namespace XFILE
287 287
 
288 288
     // sort grouped list by label
289 289
     if (items.Size() > 1 && !group.empty())
290  
-      items.Sort(SORT_METHOD_LABEL_IGNORE_THE, SortOrderAscending);
  290
+      items.Sort(SortByLabel, SortOrderAscending, SortAttributeIgnoreArticle);
291 291
 
292 292
     // go through and set the playlist order
293 293
     for (int i = 0; i < items.Size(); i++)
8  xbmc/filesystem/UPnPDirectory.cpp
@@ -355,10 +355,10 @@ CUPnPDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items)
355 355
         items.SetContent(content);
356 356
         if (content == "unknown")
357 357
         {
358  
-          items.AddSortMethod(SORT_METHOD_UNSORTED, 571, LABEL_MASKS("%L", "%I", "%L", ""));
359  
-          items.AddSortMethod(SORT_METHOD_LABEL_IGNORE_FOLDERS, 551, LABEL_MASKS("%L", "%I", "%L", ""));
360  
-          items.AddSortMethod(SORT_METHOD_SIZE, 553, LABEL_MASKS("%L", "%I", "%L", "%I"));
361  
-          items.AddSortMethod(SORT_METHOD_DATE, 552, LABEL_MASKS("%L", "%J", "%L", "%J"));
  358
+          items.AddSortMethod(SortByNone, 571, LABEL_MASKS("%L", "%I", "%L", ""));
  359
+          items.AddSortMethod(SortByLabel, SortAttributeIgnoreFolders, 551, LABEL_MASKS("%L", "%I", "%L", ""));
  360
+          items.AddSortMethod(SortBySize, 553, LABEL_MASKS("%L", "%I", "%L", "%I"));
  361
+          items.AddSortMethod(SortByDate, 552, LABEL_MASKS("%L", "%J", "%L", "%J"));
362 362
         }
363 363
     }
364 364
 
12  xbmc/filesystem/test/TestRarFile.cpp
@@ -202,7 +202,7 @@ TEST(TestRarFile, StoredRAR)
202 202
   reffile = XBMC_REF_FILE_PATH("xbmc/filesystem/test/refRARstored.rar");
203 203
   URIUtils::CreateArchivePath(strrarpath, "rar", reffile, "");
204 204
   ASSERT_TRUE(XFILE::CDirectory::GetDirectory(strrarpath, itemlist));
205  
-  itemlist.Sort(SORT_METHOD_FULLPATH, SortOrderAscending);
  205
+  itemlist.Sort(SortByPath, SortOrderAscending);
206 206
 
207 207
   /* /reffile.txt */
208 208
   /*
@@ -286,7 +286,7 @@ TEST(TestRarFile, StoredRAR)
286 286
 
287 287
   itemlist.Clear();
288 288
   ASSERT_TRUE(XFILE::CDirectory::GetDirectory(strpathinrar, itemlist));
289  
-  itemlist.Sort(SORT_METHOD_FULLPATH, SortOrderAscending);
  289
+  itemlist.Sort(SortByPath, SortOrderAscending);
290 290
 
291 291
   /* /testdir/reffile.txt */
292 292
   strpathinrar = itemlist[1]->GetPath();
@@ -367,7 +367,7 @@ TEST(TestRarFile, StoredRAR)
367 367
 
368 368
   itemlist.Clear();
369 369
   ASSERT_TRUE(XFILE::CDirectory::GetDirectory(strpathinrar, itemlist));
370  
-  itemlist.Sort(SORT_METHOD_FULLPATH, SortOrderAscending);
  370
+  itemlist.Sort(SortByPath, SortOrderAscending);
371 371
 
372 372
   /* /testdir/testsubdir/reffile.txt */
373 373
   strpathinrar = itemlist[0]->GetPath();
@@ -428,7 +428,7 @@ TEST(TestRarFile, NormalRAR)
428 428
   reffile = XBMC_REF_FILE_PATH("xbmc/filesystem/test/refRARnormal.rar");
429 429
   URIUtils::CreateArchivePath(strrarpath, "rar", reffile, "");
430 430
   ASSERT_TRUE(XFILE::CDirectory::GetDirectory(strrarpath, itemlist));
431  
-  itemlist.Sort(SORT_METHOD_FULLPATH, SortOrderAscending);
  431
+  itemlist.Sort(SortByPath, SortOrderAscending);
432 432
 
433 433
   /* /reffile.txt */
434 434
   strpathinrar = itemlist[1]->GetPath();
@@ -508,7 +508,7 @@ TEST(TestRarFile, NormalRAR)
508 508
 
509 509
   itemlist.Clear();
510 510
   ASSERT_TRUE(XFILE::CDirectory::GetDirectory(strpathinrar, itemlist));
511  
-  itemlist.Sort(SORT_METHOD_FULLPATH, SortOrderAscending);
  511
+  itemlist.Sort(SortByPath, SortOrderAscending);
512 512
 
513 513
   /* /testdir/reffile.txt */
514 514
   strpathinrar = itemlist[1]->GetPath();
@@ -589,7 +589,7 @@ TEST(TestRarFile, NormalRAR)
589 589
 
590 590
   itemlist.Clear();
591 591
   ASSERT_TRUE(XFILE::CDirectory::GetDirectory(strpathinrar, itemlist));
592  
-  itemlist.Sort(SORT_METHOD_FULLPATH, SortOrderAscending);
  592
+  itemlist.Sort(SortByPath, SortOrderAscending);
593 593
 
594 594
   /* /testdir/testsubdir/reffile.txt */
595 595
   strpathinrar = itemlist[0]->GetPath();
4  xbmc/input/ButtonTranslator.cpp
@@ -529,7 +529,7 @@ bool CButtonTranslator::Load(bool AlwaysLoad)
529 529
       CFileItemList files;
530 530
       XFILE::CDirectory::GetDirectory(DIRS_TO_CHECK[dirIndex], files, ".xml");
531 531
       // Sort the list for filesystem based priorities, e.g. 01-keymap.xml, 02-keymap-overrides.xml
532  
-      files.Sort(SORT_METHOD_FILE, SortOrderAscending);
  532
+      files.Sort(SortByFile, SortOrderAscending);
533 533
       for(int fileIndex = 0; fileIndex<files.Size(); ++fileIndex)
534 534
       {
535 535
         if (!files[fileIndex]->m_bIsFolder)
@@ -548,7 +548,7 @@ bool CButtonTranslator::Load(bool AlwaysLoad)
548 548
           CFileItemList files;
549 549
           XFILE::CDirectory::GetDirectory(devicedir, files, ".xml");
550 550
           // Sort the list for filesystem based priorities, e.g. 01-keymap.xml, 02-keymap-overrides.xml
551  
-          files.Sort(SORT_METHOD_FILE, SortOrderAscending);
  551
+          files.Sort(SortByFile, SortOrderAscending);
552 552
           for(int fileIndex = 0; fileIndex<files.Size(); ++fileIndex)
553 553
           {
554 554
             if (!files[fileIndex]->m_bIsFolder)
6  xbmc/interfaces/json-rpc/AudioLibrary.cpp
@@ -638,14 +638,14 @@ bool CAudioLibrary::FillFileItemList(const CVariant &parameterObject, CFileItemL
638 638
     // If we retrieved the list of songs by "artistid"
639 639
     // we sort by album (and implicitly by track number)
640 640
     if (artistID != -1)
641  
-      list.Sort(SORT_METHOD_ALBUM_IGNORE_THE, SortOrderAscending);
  641
+      list.Sort(SortByAlbum, SortOrderAscending, SortAttributeIgnoreArticle);
642 642
     // If we retrieve the list of songs by "genreid"
643 643
     // we sort by artist (and implicitly by album and track number)
644 644
     else if (genreID != -1)
645  
-      list.Sort(SORT_METHOD_ARTIST_IGNORE_THE, SortOrderAscending);
  645
+      list.Sort(SortByArtist, SortOrderAscending, SortAttributeIgnoreArticle);
646 646
     // otherwise we sort by track number
647 647
     else
648  
-      list.Sort(SORT_METHOD_TRACKNUM, SortOrderAscending);
  648
+      list.Sort(SortByTrackNumber, SortOrderAscending);
649 649
 
650 650
   }
651 651
 
2  xbmc/interfaces/json-rpc/FileOperations.cpp
@@ -314,7 +314,7 @@ bool CFileOperations::FillFileItemList(const CVariant &parameterObject, CFileIte
314 314
       CDirectory directory;
315 315
       if (directory.GetDirectory(strPath, items, extensions))
316 316
       {
317  
-        items.Sort(SORT_METHOD_FILE, SortOrderAscending);
  317
+        items.Sort(SortByFile, SortOrderAscending);
318 318
         CFileItemList filteredDirectories;
319 319
         for (unsigned int i = 0; i < (unsigned int)items.Size(); i++)
320 320
         {
304  xbmc/music/GUIViewStateMusic.cpp
@@ -82,20 +82,16 @@ CGUIViewStateMusicSearch::CGUIViewStateMusicSearch(const CFileItemList& items) :
82 82
   if (strAlbumRight.IsEmpty())
83 83
     strAlbumRight = "%A"; // artist
84 84
 
  85
+  SortAttribute sortAttribute = SortAttributeNone;
85 86
   if (CSettings::Get().GetBool("filelists.ignorethewhensorting"))
86  
-  {
87  
-    AddSortMethod(SORT_METHOD_TITLE_IGNORE_THE, 556, LABEL_MASKS("%T - %A", "%D", "%L", "%A"));  // Title, Artist, Duration| empty, empty
88  
-    SetSortMethod(SORT_METHOD_TITLE_IGNORE_THE);
89  
-  }
90  
-  else
91  
-  {
92  
-    AddSortMethod(SORT_METHOD_TITLE, 556, LABEL_MASKS("%T - %A", "%D", "%L", "%A"));  // Title, Artist, Duration| empty, empty
93  
-    SetSortMethod(SORT_METHOD_TITLE);
94  
-  }
  87
+    sortAttribute = SortAttributeIgnoreArticle;
  88
+
  89
+  AddSortMethod(SortByTitle, sortAttribute, 556, LABEL_MASKS("%T - %A", "%D", "%L", "%A"));  // Title, Artist, Duration| empty, empty
  90
+  SetSortMethod(SortByTitle, sortAttribute);
95 91
 
96 92
   const CViewState *viewState = CViewStateSettings::Get().Get("musicnavsongs");
97 93
   SetViewAsControl(viewState->m_viewMode);
98  
-  SetSortOrder(viewState->m_sortOrder);
  94
+  SetSortOrder(viewState->m_sortDescription.sortOrder);
99 95
 
100 96
   LoadViewState(items.GetPath(), WINDOW_MUSIC_NAV);
101 97
 }
@@ -127,12 +123,16 @@ CGUIViewStateMusicDatabase::CGUIViewStateMusicDatabase(const CFileItemList& item
127 123
   CLog::Log(LOGDEBUG,"Album format left  = [%s]", strAlbumLeft.c_str());
128 124
   CLog::Log(LOGDEBUG,"Album format right = [%s]", strAlbumRight.c_str());
129 125
 
  126
+  SortAttribute sortAttribute = SortAttributeNone;
  127
+  if (CSettings::Get().GetBool("filelists.ignorethewhensorting"))
  128
+    sortAttribute = SortAttributeIgnoreArticle;
  129
+