Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Natural Sorting in the Group GUI #4214

Closed
DorpsGek opened this issue Nov 10, 2010 · 7 comments
Closed

Natural Sorting in the Group GUI #4214

DorpsGek opened this issue Nov 10, 2010 · 7 comments
Labels
component: interface This is an interface issue flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) patch from FlySpray This issue is in fact a Patch, but imported from FlySrpay

Comments

@DorpsGek
Copy link
Member

MagicBuzz opened the ticket and wrote:

Here is a patch for natural sorting in the Group GUI.

As a result, when nanimg groups using numbers, they will be sorted accorting number ascending order ie:

Group0
Group1
Group2
[...]
Group9
Group10
instead of
Group0
Group1
Group10
Group11
[...]
Group2
Group20
[...]

This patch uses a GNU natsort implementation of Martin Pool found at sourceforge.

Attachments

Reported version: trunk
Operating system: All


This issue was imported from FlySpray: https://bugs.openttd.org/task/4214
@DorpsGek
Copy link
Member Author

SmatZ wrote:

That patch can't be applied due to those copyright restrictions.


This comment was imported from FlySpray: https://bugs.openttd.org/task/4214#comment9058

@DorpsGek
Copy link
Member Author

MagicBuzz wrote:

Which copyright restrictions ?

On the sourceforge web site, it's wrote this code can be distributed like zlib can be. OTTD actually uses zlib, so why can't it use this code ?
Also, in the comments of this code itself, it's wrote anyone can use it, modify it as free as he can, for personnal or commercial use. The only restriction is that the comments in strnatcmp.cpp and strnatcmp.h must not be removed, and a reference to the author should be included in the final program documentation.

If needed I could rewrite the strnatcmp function, but I'm affraid I'll produce something very similar as the current implementation of the algorythm is quite standard...


This comment was imported from FlySpray: https://bugs.openttd.org/task/4214#comment9059

@DorpsGek
Copy link
Member Author

MagicBuzz wrote:

Ok, then I removed the code from Martin Pool and used a discontinued patch instead :

#2284 - Natural sort for names in vehicle lists - r14276
Opened by Gabor Heja (kakaopor) - Tuesday, 09 September 2008, 07:52 GMT

strnatcmp.cpp and strnatcmp.h should no longer have copyright issues I guess.

I also changed most GUI windows in order to use strnatcmp instead of strcmp for name sorting (vehicle name, industry name, cargotype name, town name, etc.)
Some were not really needed (cargo and town by exemple) but I think it's more elegant to use the same sorting function everywhere. Thus it could be usefull for people who are working on newgrf and still didn't set readable names to those things.


This comment was imported from FlySpray: https://bugs.openttd.org/task/4214#comment9060

@DorpsGek
Copy link
Member Author

MagicBuzz wrote:

Here is the patch for trunk r21131

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/4214#comment9061

@DorpsGek
Copy link
Member Author

Rubidium wrote:

Interestingly sorting numbers is only a (small) subset of properly supporting natural sorting of strings. To do it properly you have to account for other things as well, e.g. in Swedish it is z < ö, but in German ö < z. Fun, right?
http://www.unicode.org/reports/tr10/ got (quite) some interesting information about all this.

Luckily it is already implemented in ICU but nobody ever bothered writing the actual code to use it, though that leaves people not using ICU with the old behaviour which isn't a problem in my opinion; they did chose NOT to have support for natural sorting strings. See http://userguide.icu-project.org/collation for more information.


This comment was imported from FlySpray: https://bugs.openttd.org/task/4214#comment9062

@DorpsGek
Copy link
Member Author

MagicBuzz wrote:

Patch update :
- Merged strnatcmp.cpp with string.cpp : strcmp and strnatcmp are virtually the same functions, so it not a bad idea I guess to put theim together
- Added nat sorting to several other windows such as towns, vehicles, cargo, industry and station

I can't understand how to work with ICU, so there is still no international natural order support.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/4214#comment9086

@DorpsGek
Copy link
Member Author

Terkhen closed the ticket.

Reason for closing: Implemented

In r21344.


This comment was imported from FlySpray: https://bugs.openttd.org/task/4214

@DorpsGek DorpsGek added component: interface This is an interface issue flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) patch from FlySpray This issue is in fact a Patch, but imported from FlySrpay labels Apr 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: interface This is an interface issue flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) patch from FlySpray This issue is in fact a Patch, but imported from FlySrpay
Projects
None yet
Development

No branches or pull requests

1 participant