Bug 14488 - sort package names in pk-application
Summary: sort package names in pk-application
Alias: None
Product: PackageKit
Classification: Unclassified
Component: General (show other bugs)
Version: unspecified
Hardware: x86 (IA32) Linux (All)
: medium enhancement
Assignee: Richard Hughes
QA Contact:
Depends on:
Reported: 2008-02-13 15:00 UTC by Ben Liblit
Modified: 2008-03-16 16:26 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Description Ben Liblit 2008-02-13 15:00:44 UTC
When pk-application shows a list of packages matching the user's search and filter criteria, it shows installed packages first followed by non-installed packages.  However, within each of those two groups, packages seem to be in arbitrary order.  I'd prefer to see installed packages be sorted by name, then non-installed packages also sorted by name.

version and configuration details:
  - PackageKit-0.1.7-0.436.20080210git.fc8.hughsie
  - gnome-packagekit-0.1.7-0.355.20080210git.fc8.hughsie
  - installed via prebuilt FC8 RPMs
  - distribution: Fedora 8
Comment 1 Richard Hughes 2008-02-13 15:22:07 UTC
Good idea. Should we sort these in the daemon, the client library or the UI application itself? I would vote for the latter as it's an interface issue.

I'm not sure how we can do this with a TreeView. Would it be the end of the world if the list was sortable and not split into installed and available?

Comment 2 Ben Liblit 2008-02-13 15:44:16 UTC
Are there are reasonable situations in which sorting is not needed?  For example, perhaps an automated tool is consuming the output and couldn't care less what order things appear in.  If that's the case, then sorting it in the GUI application seems sensible.  I don't really have a strong opinion on this.

Sorting the GtkTreeView should be possible.  The API offered by GtkTreeSortable (http://library.gnome.org/devel/gtk/unstable//GtkTreeSortable.html) seems rich enough.  It ultimately comes down to a binary comparison function.  So pseudo-code like the following ought to work:

    compare(package a, package b):
        if a.installed and not b.installed:
            return -1
            return stringCompare(a.name, b.name)

You'd effectively be doing a lexical sort on (installed, name) tuples.

I suppose an alternative would be to have "Installed" and "Name" column headings that the user could click to sort.  If changing sort criteria uses a stable sort, then clicking "Name" followed by "Installed" would leave the list grouped by install status and then sorted by name within each group.

I have limited technical knowledge of tree views/models/sorts, so I'll stop speculating on how this *could* be done.  But it ought to be feasible.
Comment 3 Richard Hughes 2008-03-16 16:26:14 UTC
I've sorted these by name, as it think it's the most obvious thing to do. Sorting by installed and then name is very tricky (you have to do 2 passes looking at both arrays) and isn't that obvious when searching for a package in the list in my opinion.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.