archi icon indicating copy to clipboard operation
archi copied to clipboard

Wrong sorting order in models tree

Open Sonique opened this issue 1 year ago • 5 comments

Version of Archi

5.2.0.202311011021 silicon mac

Archi Plug-ins

yep

Operating System

mac silicon

Expected Behaviour

alphanumeric sorting

Actual Behaviour

character sorting

Steps to Reproduce the Behaviour

  1. create folders with numerals in naming like folder-15 folder-100
  2. look up in tree
  3. folder 100 will be first
image

Sonique avatar Jul 02 '24 09:07 Sonique

This is expected behaviour and can't be changed. Text comparison is based on the Java Collator class. This provides lexical comparison based on locale to account for characters like accents.

Phillipus avatar Jul 02 '24 10:07 Phillipus

So how can it be changed? Because it's terrible behaviour for sorting, it's not usable at all, maybe only for Wittgenstein Tractatus table of content is good, but not for other cases. Digital sequences should be compared as numbers not as literals one by one.

More over most editors sort in the right way.

Look for example on Intellij Idea on same system

image

So I see it more as bug then expected behaviour

Sonique avatar Jul 03 '24 08:07 Sonique

So how can it be changed?

As I explained, in Java sorting is done by the Collator class. If you wish, as Archi is open source, you can provide your own solution.

Phillipus avatar Jul 03 '24 08:07 Phillipus

For reference - https://github.com/farbodsafaei/alphanumeric-comparator

Phillipus avatar Jul 03 '24 15:07 Phillipus

I'll keep the issue open. There are third-party implementations of an AlphaNumericComparator such as the link in the previous comment but I don't know what the impact is in performance. The implementation needs to support Collator.getInstance() so that Locale based sorting is also supported. Needs more investigation.

Phillipus avatar Jul 04 '24 09:07 Phillipus