locale aware song sorting

This commit is contained in:
M2j 2010-12-09 16:08:04 +01:00
parent 465515d71e
commit 7e221a6e98

View File

@ -25,6 +25,7 @@
###############################################################################
import logging
import locale
import re
from PyQt4 import QtCore, QtGui
@ -215,6 +216,7 @@ class SongMediaItem(MediaManagerItem):
def displayResultsSong(self, searchresults):
log.debug(u'display results Song')
self.listView.clear()
searchresults.sort(cmp=self.collateSongTitles)
for song in searchresults:
author_list = u''
for author in song.authors:
@ -439,3 +441,9 @@ class SongMediaItem(MediaManagerItem):
if editId != 0:
Receiver.send_message(u'service_item_update',
u'%s:%s' %(editId, uuid))
def collateSongTitles(self, song_1, song_2):
"""
Locale aware collation of song titles
"""
return locale.strcoll(unicode(song_1.title), unicode(song_2.title))