HyperFile: Sorting strings with leading spaces

Startbeitrag von Jimbo am 16.08.2009 15:56

Hi all,

I believe that there is something very strange within the string sorting algorithm of HyperFile. Please add your comments if you think that there is something wrong in my findings:

In order to feed a simple file item for selection purposes to combo boxes, I build a string using a trigger.

example file
CUSTGROUP (Customer group)

CUSTGR_NUM customer group# range 1 - 9999
CUSTGR_TXT customer group name
CUSTGR_NUMTXT a string composite of number and text which will be used by combos

The one-code-line global procedure triggered by each HAdd or HModify looks as follows

CUSTGR_NUMTXT = NumToString(CUSTGR_NUM,"4d")+" - "+ Nospace(CUSTGR_TXT)

this will give a simple to read content of the combo for selection of a customer group. The combo for customer group 17 will look like this:

[ 17 - Customers without money ]

note the two spaces in front of the 17, which should take care for the correct sorting within the CUSTGR_NUMTXT file item.

Surprise! All of the strings with leading spaces are NOT sorted correctly but rather erratically where I can see some but not really much of a logic behind! Here is an example - the marked line starting with a 10 - should be the first in the sorted view of the HyperFile Control Center, but it is not!



When I change the code line of the global procedure in order to show something else than leading spaces (e.g. dots, everything below ascii 48 decimal) the sorting will still be wrong! Putting a single character at the start of the string - the sort order is still wrong!

Only with zeroes as leading characters, the sort sequence is correct. Nothing else works!

Putting any repeated character in front of the first figures will reduce its readability a lot. And it doesn't look very professional.

Has anybody a good idea / solution?

Kind regards,
Guenter





Antworten:

Hello Guenter

Have you checked the sort options for the combo box, they may be set to something you are not expecting. One of the options allows you to set the space options and there is another to sort numeric strings on their numeric values.

Regards
Al

von Al - am 16.08.2009 16:10

Solution

Easy: In the analysis, make the field sorting sensitive to *spaces*, accents and punctuation characters by checking the approprite check box!





von Jimbo - am 16.08.2009 16:14

Hi Al,

thanks and no, I didn't. I had been completely surprised by the stubborn non-sorting of the field!

Kind regards,
Guenter


von Jimbo - am 16.08.2009 16:17
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.