[FIXED] Account Screen not sorting correctly

While writing my Expenses and Payouts - Method K tutorial I came across an interesting bug. My accounts screen is not sorting correctly for some reason. I have no idea why. My Misc Expenses accounts is showing under my Sales. I have sorted it to show at the end of General Screen yet it still shows under Sales.


I noticed that as well. It’s because the leading numbers on the Account Type are being sorted alphabetically instead of numerically.

10       10
100      20
20       30
30       40
40      ...
50      100

@emre may be able to fix this to sort properly, but the issue exists in many areas of the program, including Product Groups, forcing us to use naming which includes leading zeros:

1     01
10    02
2     ...
...   09
9     10

I see. Minor inconvenience. Will be nice when or if he fixes it but using leading zeros as names is not a bad thing.

@QMcKay can you let me remember where we’re sorting by product group? Printer Template?

Sorry @emre, I think I meant to say Product Tags, in Printer Templates. There may be other areas as well though, since we also see this on the Account Screens.

Personally, I don’t use leading-numbers in any of my naming conventions, but I remember replying to more than one post instructing the user to add a leading zero to numbers less than 10 so that they would sort properly. Here is one…

1 Like

It looks to me like its sorting by the first number and not looking at the whole number… it sees 10 and 100 as the same however it would see 110 as 11 and 120 as 12. I am not sure how it chooses to sort once it hits that point tho. I could be wrong but this is what it seems like.

@Jesse fixed.
@QMcKay fixed.

Adding numbers to alphanumeric values does not converts that value to a number even you use only numbers. So it is just an alphanumeric comparison. It works fine until 1-9 but when alphanumerically sorted it becomes:


just like


Since bbb is not greater than a, 222 is not greater than 1.

So what we need to do is implementing a custom sorting that extracts numbers from strings and sorts them first by numeric values and alphabetically. This is an expensive sorting method but I don’t think that will make a lot performance difference on printout grouping.


I see the sorting was fixed with one of the latest releases! Thank you!