Inability to sort with several option

Bug #136042 reported by Adam Olsen
4
Affects Status Importance Assigned to Milestone
Exaile
Fix Released
Wishlist
Unassigned
exaile (Debian)
Fix Released
Unknown

Bug Description

A slightly annoying issue I'm having with Exaile is this:

I'd like to sort my music with several options:

I want the "master" option to be by artist, so that all the artist's albums and tracks are listed in one block. Furthermore, I want to "slave"-options:

First, that the music is sorted in blocks of albums (I only have full albums on my playlist), as well as in the track order on that album, rather than having the tracks appear alphabetically in my blocks of one artist's tracks.

It's possible that this already exists, but I was unable to find it.

This ticket was migrated from the old trac: re #432

Adam Olsen (arolsen)
Changed in exaile:
importance: Undecided → Wishlist
status: New → Confirmed
Revision history for this message
François Févotte (francois-fevotte) wrote :

Hello,

I also got the same wish from a Debian user. It would indeed be cool if the playlist sorting system could be more flexible. As the original Debian bug reporter suggests, there exist several options to do this:
* remember previous sorting keys and use them in (reverse) order as secundary sorting keys
* allow several multi-key sorting profiles, much like it was done for bug #136100

Thanks,

   François

Changed in exaile:
status: Unknown → Confirmed
Revision history for this message
Ewan Higgs (ewan-higgs) wrote :

I think the way to do this is with a stable sort. That means that the current sort order is kept when you sort again by a different criteria. For example, if you were to sort by track number, and then album, you would see all the albums sorted by track number.

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.

Revision history for this message
Adam Olsen (arolsen) wrote : Re: [Bug 136042] Re: Inability to sort with several option

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Can you submit a patch?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: http://firegpg.tuxfamily.org

iD8DBQFHaBRhTSjho5GlGw8RAr3iAKDEm4qTOUeXspBFYea08rHHiO27WQCgpEAV
079P4kdApUsRrir5rqDoqXE=
=9dXq
-----END PGP SIGNATURE-----

On Dec 15, 2007 9:27 PM, Ewan Higgs <email address hidden> 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.
>
>
> --
> Inability to sort with several option
> https://bugs.launchpad.net/bugs/136042
> You received this bug notification because you are a direct subscriber
> of the bug.
>

--
Adam Olsen
SendOutCards.com
http://www.vimtips.org
http://last.fm/user/synic

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

Sorry for the delay in getting back to you.
I am attaching the output of the diff command so you can run patch on the file. If you need this in another format, let me know. Thanks

Revision history for this message
Adam Olsen (arolsen) wrote :

Patch committed

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

Patch was committed ages ago and it's working perfect for me in 0.2.14. Can we close this?

Adam Olsen (arolsen)
Changed in exaile:
status: Confirmed → Fix Released
Changed in exaile (Debian):
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.