Listbox Sorting numbers - Forum

Forum Navigation
You need to log in to create posts and topics.

Listbox Sorting numbers

I am trying to use a listbox to sort strings that begin with numbers, and it's not sorting.  I even placed a sort command at the end of the function to be SURE, and I still get the following.

100
25
25
50

Does anyone have any idea how I can address this ?

Thanks

 

Hello,

You may have a look at hpwLineSort from hpwControl;

hpwLineSort "[ListboxItems]" "NA" "[ListboxItems]"

NA = Numbers ascending

Regards

Hans-Peter

 

 

rcohen has reacted to this post.
rcohen

Ahh handy plugin... I guess I should just go ahead and use it ;-)

I see many of your plugins list as for VNW only.   Will this work in NB still, as I have intentions to upgrade, but haven't yet.

Thanks Hans!

rcohen

@rcohen

Here would be my guess: You have no leading zeros. Think of it sorting alphabetically; Aardvark comes before Apple, even though aardvark has more letters, Aa comes before Ap. So, in your example, 1 comes before 2, 2 comes before 5, etc.

It's like they say when comparing version numbers: Sometimes 20 is bigger than 100.

It's a frustrating issue especially when I deal with Access DBs and sort a record ID field, for instance. I have to write code to add leading zeros in order to sort asc or dec correctly.

rcohen has reacted to this post.
rcohen

That actually crossed my mind, but I didn't try it.    I'll keep that in mind if Hans's solution doesn't work out for me.   I'm not a coder, so some things even in NB are a bit over my head.

Thanks for the thought / confirmation, Paul

rcohen