Comment 3 for bug 136042

Revision history for this message
Ewan Higgs (ewan-higgs) wrote :

To fix this, edit exaile/xl/gui/playlist.py.

Add a line to 'import operator'

Then edit reorder_songs(self, songs) to read as follows:

    def reorder_songs(self, songs):
        """
            Resorts all songs
        """
        attr, reverse = self.get_sort_by()

        def the_strip(tag):
            return spec_strip(library.the_cutter(tag))
        def spec_strip(tag):
            return library.lstrip_special(tag)

        if attr in ('album', 'title'):
            get_key = lambda track: spec_strip(getattr(track, attr).lower())
        elif attr == 'artist':
            get_key = lambda track: the_strip(track.artist.lower())
        elif attr == 'length':
            get_key = lambda track: track.get_duration()
        else:
            get_key = lambda track: getattr(track, attr)

        s = [
            (get_key(track),
            track)
            for track in songs]

        s = sorted(s, key=operator.itemgetter(0), reverse=reverse)

        songs = [track[-1] for track in s]
        return songs

This will allow you to change the sort order on each column, but maintain the previous order for all rows that have the same value. For example, if you want to group all your albums together by artist and keep the track order, you would click track, then album, and then artist.