You could either maintain a dummy column that contained a string formatted how you want it to sort, or you could use a sort function.
I thought there was an example of queue function sorting somewhere. You write a function that receives 2 *GROUPS, where you put the logic for which group is sorted first. But personally, I’d probably go with option 1
a) format the strings so they are numbers of fixed length - eg 001 not 1
b) use a “sort” column in the queue, usually invisible, and populate this with formatted strings (as per a above ) and sort on this.
c) create a custom Q sort function. If you have Stringtheory, look in Stringtheory.clw for an example of doing this - there are 3 functions (not methods) in there called SortCaseSensitive, SortCaseInsensitive and SortLength. For example;
!-----------------------------------------------------------------------------------
SortCaseInsensitive Procedure(*LinesGroupType p1,*LinesGroupType p2)
code
if Upper(p1.line) = Upper(p2.line) then return 0.
if Upper(p1.line) > Upper(p2.line) then return 1.
return -1
The hidden Sort field is the easiest. You can have the column visible while developing to debug. This code would not work to put 100A after 100, but will work with your example of A100.
IF Numeric(Q:Code) THEN
Q:SortCode=FORMAT(0+Q:Code,@n_10)
ELSE
Q:SortCode=UPPER(Q:Code)
END
For the best examples of Queue sorting search Clarion Live for Simon Kemp and you’ll find:
#348 Simon Kemp On Queue Functional Sorting
FEB 19,2016 Simon Kemp
This week, it’s Functional Queue Sorting with Simon Kemp! What is Functional Queue Sorting? I have no idea! But I’m looking forward to finding out!!!
#350 Simon Kemp On Queue Functional Sorting Part2
MAR 04,2016 Simon Kemp
Get the code here --> (not specified) This week, it’s Functional Queue Sorting Part 2 with Simon Kemp! Two weeks ago, Simon started showing us about Functional Queue Sorting, but he had so much to show he couldn’t fit it into one webinar! Join him for Part 2 and learn even more amazing things about queue sorting!
Simon’s website changed from SdkSoftwaresolutions.com to http://sdksoftware.uk/ and has the download SdkLCS.zip used in the webinar. I had it and attached it here. Its very very useful, probably showing every possible Queue Sort function.
Very kind of you Carl, I tried hard on that ClarionLive stuff. And (if I’m honest) can’t recall the last time I found a use case. Pretty obscure stuff.
My domain changed to sdksoftware.uk a while ago…
From the Webinar I easily recalled your initials were S.D.K. (as in “Software Dev Kit”) but searches for “SDK Software Simon Kemp” did not find it. Maybe you need to add some that SEO search word stuff.
The 2 Webinars completely cover Q sorting very well, and your example APP is great for having working code to use.