Bug 335129

Summary: Wrong account ordering at home page
Product: kmymoney Reporter: Josef Kufner <jk>
Component: generalAssignee: KMyMoney Devel Mailing List <kmymoney-devel>
Status: RESOLVED FIXED    
Severity: normal CC: christian-david, onet.cristian, ostroffjh
Priority: NOR    
Version: 4.6.4   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: Sorting in the home page.
Sorting in the accounts view.

Description Josef Kufner 2014-05-21 10:26:30 UTC
At home page, Assets and Liabilities Summary section, accounts are not sorted correctly when the first letter is not in ASCII.

Reproducible: Always

Steps to Reproduce:
1. Create accounts: A, Z, C, Č
2. Accounts page: accounts are in correect order: A, C, Č, Z
2. Home page: accounts are in wrong order: A, C, Z, Č


Expected Results:  
Accounts at Home page should be in correct alphabetical order (respecting locale settings and wierd characters).

strcmp() in sorting function does not work, strcoll is much better.
Comment 1 Thomas Baumgart 2014-05-21 12:22:57 UTC
Since we use Qt you mean QString::localeAwareCompare()
Comment 2 Cristian Oneț 2014-05-25 14:14:02 UTC
Git commit e212103d46f3b4a5b37f4c94ebd8b3271993abd1 by Cristian Oneț.
Committed on 25/05/2014 at 14:07.
Pushed by conet into branch 'master'.

Account ordering by name on the home page is now locale aware.

Since QMap does not allow setting the comparator function for each
instance of the map (qMapLessThanKey is for the whole class) we droped
using it just to obtain a collection ordered by the account name.
Use an account list instead and sort it using the proper comparator
before rendering it.

M  +29   -48   kmymoney/views/khomeview.cpp

http://commits.kde.org/kmymoney/e212103d46f3b4a5b37f4c94ebd8b3271993abd1
Comment 3 Josef Kufner 2014-05-25 14:41:30 UTC
Thank you!
Comment 4 Cristian Oneț 2014-05-25 14:51:59 UTC
(In reply to comment #3)
> Thank you!
You're welcome.
Comment 5 Jack 2014-05-28 23:49:04 UTC
I was about to file a similar bug based on a mailing list request some weeks ago, but I'm not sure if it's the same issue.  This bug referred to usign non-ASCII characters, but my case is completely within US English, so locale should not be an issue.  On the accounts page, the order is "Checking One" "CHECKING ONE" "CHECKING TWO" but on the home page, it is "CHECKING ONE" "CHECKING TWO" "Checking One".  The original complaint on the mailing list was about the difference between the home page and any dropdown with a list of accounts, but I suspect it's the same issue.  I just tried KMM compiled from git, and I still see the issue.  Is this a separate bug, or might I have a configuration issue?
Comment 6 Christian David 2014-05-29 09:18:24 UTC
(In reply to comment #5)
> I was about to file a similar bug based on a mailing list request some weeks
> ago, but I'm not sure if it's the same issue.  This bug referred to usign
> non-ASCII characters, but my case is completely within US English, so locale
> should not be an issue.  On the accounts page, the order is "Checking One"
> "CHECKING ONE" "CHECKING TWO" but on the home page, it is "CHECKING ONE"
> "CHECKING TWO" "Checking One".
your problem should be caused by the compare method as well. As in non-local aware comparison only the ASCII (or UTF-8) values are compared and so any lowercase letter is behind all uppercase letters ( ddg.gg/?q=ascii+table ).

Btw: you should always use local aware comparison where the user expects a human sorting method, also in english-only texts. This ensures correct sorting of special chars as well (plain ASCII sort would generate this list: "!6;A]z}", but no human would expect that).
Comment 7 Cristian Oneț 2014-06-10 20:11:52 UTC
(In reply to comment #5)
> I was about to file a similar bug based on a mailing list request some weeks
> ago, but I'm not sure if it's the same issue.  This bug referred to usign
> non-ASCII characters, but my case is completely within US English, so locale
> should not be an issue.  On the accounts page, the order is "Checking One"
> "CHECKING ONE" "CHECKING TWO" but on the home page, it is "CHECKING ONE"
> "CHECKING TWO" "Checking One".  The original complaint on the mailing list
> was about the difference between the home page and any dropdown with a list
> of accounts, but I suspect it's the same issue.  I just tried KMM compiled
> from git, and I still see the issue.  Is this a separate bug, or might I
> have a configuration issue?

Jack, I think there is something wrong in the version that you tested this, are you sure that the patch that fixes this issue is contained? I'm asking because I'm not seeing what you report. On the homepage I see 
"Checking One"
"CHECKING ONE"
"CHECKING TWO"
the same goes for the accounts and any drop-down that shows accounts.

The only place I still see this issue is in reports.
Comment 8 Cristian Oneț 2014-06-10 20:12:50 UTC
Created attachment 87117 [details]
Sorting in the home page.
Comment 9 Cristian Oneț 2014-06-10 20:13:20 UTC
Created attachment 87118 [details]
Sorting in the accounts view.
Comment 10 Jack 2014-06-10 20:19:29 UTC
(In reply to comment #7)
I will try again, but it may be a few days.  I'm pretty sure my last test was from git Master, so it sounds like the patch SHOULD be there.  I'll try to confirm for sure when I get to test again.  It's certanly possible I wasn't using the source I thought I was.