Bug 355255

Summary: enh: let yast2 sort in more readable manner
Product: [openSUSE] openSUSE 11.1 Reporter: Casual J. Programmer <casualprogrammer>
Component: libzyppAssignee: Duncan Mac-Vicar <dmacvicar>
Status: RESOLVED FIXED QA Contact: Duncan Mac-Vicar <dmacvicar>
Severity: Minor    
Priority: P2 - High CC: casualprogrammer, holler, locilka, ma
Version: Alpha 0   
Target Milestone: Alpha 0   
Hardware: x86   
OS: openSUSE 11.0   
Whiteboard: maint:released:11.0:21174
Found By: Beta-Customer Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Bug Depends on:    
Bug Blocks: 355258    

Description Casual J. Programmer 2008-01-22 12:02:01 UTC
As pointed out in Bug 350809 Comment #2

"packages not sorted in any fashion, clicking on the column header ( which would
normally sort after this columns content ) achieves nothing."

Clicking on the column header now sorts the items displayed, but sort order is binary not alphabetical.

Consider testfile containing:

cat testfile
Abc
abc
bcd
BCD
Bcd
BcD
123
4bb
3nn
zyp
bte
654
987
234
Ber
Reg
GGv
GGG
ggg
ggV

then 

cat testfile | sort

123
234
3nn
4bb
654
987
Abc
BCD
BcD
Bcd
Ber
GGG
GGv
Reg
abc
bcd
bte
ggV
ggg
zyp

which is a binary sort enforced by setting RC_LC_ALL to C in /etc/sysconfig/language

What I ( and most probably the majortity of useres ) would prefer is an alphabetical sort order as

cat testfile | sort

123
234
3nn
4bb
654
987
abc
Abc
bcd
Bcd
BcD
BCD
Ber
bte
ggg
GGG
ggV
GGv
Reg
zyp

As sort --help points out :

*** WARNING ***
The locale specified by the environment affects sort order.
Set LC_ALL=C to get the traditional sort order that uses
native byte values.

So a fix would involve making yast2 sw_single honor the locale environment variables for sort order.
Comment 1 Casual J. Programmer 2008-01-22 12:03:32 UTC
Notebook: Fujitsu Siemens Amilo Si 1520
Graphics: Fujitsu Siemens Mobile 945GM/GMS/GME, 943/940GML Express
Monitor:  QUANTADISPLAY LCD Monitor 1280x800@60Hz
Wireless: Intel PRO/Wireless 3945ABG Network Connection
Sound:    82801G (ICH7 Family) High Definition Audio Controller
Desktop:  gnome2-SuSE-10.3-141
YaST GUI: yast2-qt-2.16.17-5
OS:       openSUSE 11.0 (i586) Alpha1 VERSION = 11.0
Kernel:   2.6.24-rc8-git1-2-default

rpm -qa | grep yast2 | sort

autoyast2-2.16.6-2
autoyast2-installation-2.16.6-2
yast2-2.16.21-2
yast2-add-on-2.16.0-32
yast2-add-on-creator-2.16.3-12
yast2-apparmor-2.1-64
yast2-autofs-2.15.3-8
yast2-backup-2.16.1-13
yast2-bluetooth-2.15.4-46
yast2-bootloader-2.16.3-13
yast2-ca-management-2.16.4-12
yast2-control-center-2.16.0-13
yast2-control-center-gnome-2.13.2-137
yast2-control-center-qt-2.16.0-13
yast2-core-2.16.22-2
yast2-core-devel-2.16.22-2
yast2-country-2.16.5-11
yast2-country-data-2.16.5-11
yast2-devel-doc-2.16.21-2
yast2-devtools-2.16.3-9
yast2-dirinstall-2.16.0-22
yast2-dns-server-2.16.1-12
yast2-fingerprint-reader-2.16.2-12
yast2-firewall-2.15.8-44
yast2-firstboot-2.16.2-25
yast2-ftp-server-2.15.9-64
yast2-gtk-2.15.9r43566-3
yast2-hardware-detection-2.16.0-17
yast2-http-server-2.15.9-13
yast2-inetd-2.15.1-81
yast2-installation-2.16.9-5
yast2-instserver-2.15.4-78
yast2-irda-2.15.1-131
yast2-iscsi-client-2.16.2-18
yast2-iscsi-server-2.14.4-5
yast2-kdump-2.16.9-5
yast2-kerberos-client-2.16.1-12
yast2-kerberos-server-2.16.0-20
yast2-ldap-2.15.1-117
yast2-ldap-client-2.16.5-12
yast2-ldap-server-2.15.5-113
yast2-mail-2.15.24-8
yast2-mail-plugins-2.15.24-8
yast2-mcs-plugin-0.1.0-71
yast2-metapackage-handler-0.7.3-22
yast2-mouse-2.16.0-22
yast2-multipath-2.13.0-122
yast2-ncurses-2.16.8-4
yast2-network-2.16.21-2
yast2-network-devel-doc-2.16.21-2
yast2-nfs-client-2.15.0-61
yast2-nfs-server-2.15.5-7
yast2-nis-client-2.16.0-32
yast2-nis-server-2.16.0-40
yast2-nis-server-devel-doc-2.16.0-40
yast2-ntp-client-2.16.2-18
yast2-online-update-2.16.6-13
yast2-online-update-frontend-2.16.6-13
yast2-packager-2.16.15-2
yast2-pam-2.16.0-33
yast2-perl-bindings-2.16.0-38
yast2-pkg-bindings-2.16.11-2
yast2-pkg-bindings-devel-doc-2.16.11-2
yast2-printer-2.16.6-16
yast2-printer-devel-doc-2.16.6-16
yast2-product-creator-2.16.6-14
yast2-profile-manager-2.16.0-23
yast2-python-bindings-2.16.2-11
yast2-qt-2.16.17-5
yast2-registration-2.16.0-24
yast2-repair-2.16.3-5
yast2-restore-2.16.0-24
yast2-ruby-bindings-0.2.0-37
yast2-runlevel-2.16.0-24
yast2-samba-client-2.16.1-22
yast2-samba-server-2.16.0-36
yast2-scanner-2.15.5-79
yast2-schema-2.15.0-156
yast2-security-2.15.1-61
yast2-slide-show-SuSELinux-2.15.16-2
yast2-slp-2.15.0-68
yast2-slp-server-2.15.0-79
yast2-sound-2.16.2-5
yast2-squid-2.16.1-2
yast2-sshd-2.16.0-18
yast2-storage-2.16.8-5
yast2-storage-devel-2.16.8-5
yast2-storage-evms-2.16.8-5
yast2-storage-lib-2.16.8-5
yast2-sudo-2.15.3-127
yast2-support-2.15.3-51
yast2-sysconfig-2.15.3-94
yast2-tftp-server-2.14.0-141
yast2-theme-openSUSE-2.16.4-6
yast2-trans-de-2.16.1-4
yast2-trans-en_US-2.15.5-23
yast2-transfer-2.16.1-6
yast2-trans-ru-2.16.1-4
yast2-trans-stats-2.15.0-50
yast2-tune-2.15.7-61
yast2-tv-2.16.3-5
yast2-update-2.16.4-2
yast2-update-FACTORY-2.16.4-2
yast2-users-2.16.5-12
yast2-x11-2.15.11-67
yast2-xml-2.16.0-16
Comment 2 Hans-Peter Holler 2008-03-05 21:32:39 UTC
Maybe a simple change from strcmp to stricmp could do the numeric before upper before lower thing.
Respecting locales and character sets would be nice _if_ someone wants to name a package/description like "kindergärten" (german plural of kindergardens).
Comment 3 Stefan Hundhammer 2008-03-07 14:15:04 UTC
This uses zypp::ResObject::operator<() , so it is something to be handled in libzypp.
Comment 4 Stefan Hundhammer 2008-03-10 16:30:23 UTC
Reassigning to zypp maintainers
Comment 5 Michael Andres 2008-03-11 11:23:59 UTC
(In reply to comment #3 from Stefan Hundhammer)
> This uses zypp::ResObject::operator<() , so it is something to be handled in
> libzypp.

No Stefan. Zypp's pool is a set and has no specific order and it would be counterproductive to define any specific/expensive order here.

I dont't think it's hard for the UI to define the sort order for each column it displays. 
Comment 6 Stefan Hundhammer 2008-03-11 14:05:27 UTC
This uses

   b = this->zyppObj()->name() < other->zyppObj()->name()

and if this operator<() doesn't work correctly, there is nothing I could do.
Feel free to WONTFIX this if that can't be changed on that level to work properly with internationalization.
Comment 7 Michael Andres 2008-03-11 14:37:39 UTC
Your code defines the sort order. You are using the std::string::operator<, and thats a plain strcmp. If you don't want to change it, leave it as it is. 

  b = strcoll( this->zyppObj()->name().c_str(), 
               other->zyppObj()->name().c_str() ) < 0
Comment 8 Duncan Mac-Vicar 2008-03-11 14:44:48 UTC
I think comment #6 is wrong.

APIs generally define the < operator as they go higher on the abstraction by keeping the lower layers semantics.

For example, if you have a class person, you will probably define the < operator based on the < operator on the name or the age, _without_ altering the semantic of those operators, and it is the UI which defines a sort policy _based_ (which means it could be the same) on the classes operators.

Almost every model controller architecture (including Qt's one) have hooks to define the sort order because the "mathematic" sort order of the frameworks not always is what you want to display to the user.

Usually changing the semantics of this means adding a one character to invert the logic, or an if to exclude some items. Is that a problem?
Comment 9 Stefan Hundhammer 2008-03-11 15:00:29 UTC
What do we have an abstraction like operator<() for if it doesn't work properly?

Of course I can duplicate everything on the UI level. But then, what are the lower levels good for?
Comment 11 Hans-Peter Holler 2008-06-16 19:50:41 UTC
11.1 ?
Comment 13 Duncan Mac-Vicar 2008-07-17 14:56:53 UTC
*** Bug 392994 has been marked as a duplicate of this bug. ***
Comment 14 Duncan Mac-Vicar 2008-08-12 16:03:50 UTC
Fixed in svn, will commit soon. Also commited to 11.0 branch so may appear as a future online update.
Comment 15 Duncan Mac-Vicar 2008-08-15 12:28:44 UTC
fixed in submitted 2.17.5
Comment 16 Swamp Workflow Management 2008-12-17 15:38:56 UTC
Update released for: 
openSUSE 11.0 (debug, i386, ppc, x86_64)