August 24, 200619 yr I am using 24uDialog to do some processing. I use 2 lists of data, and compare them. I want to create a custom function that will sort a block of data line by line. I figure I have to use a recursive CF for this, and I've been unable thus far to wrap my head around recursive CFs. So, if I send this data to the CF: 523456 Account Name Yada 1239384 Account Name More 7346234 Account Name Yeah I want it to return: 1239384 Account Name More 523456 Account Name Yada 7346234 Account Name Yeah Help or suggestions? Thanks! Brian Hightower
August 25, 200619 yr Since it looks like you just need to sort it alphabetically, you can use one of the sorting CFs on briandunning.com. I happen to like the quicksort algorithm. This algorithm requires a couple sub functions to break the problem down into different pieces. Jeremy's version is missing the ValuesGreaterThanOrEqual() sub function, but you should be able to derive that based on how the ValuesLessThanOrEqual() function works.
August 27, 200619 yr Author Well, I managed to find a full version of the Quicksort() and 2 add'l functions. They are stored in an example file for the Mode() function. The strange thing about this function, is that it will sort numbers fine. I gave it a series of numbers, and it returned them fine each time. When I added text the the mix, it became completely unpredictable. I tested this code in the Data Viewer: Let( [ X1 = "8¶78¶387¶69879¶2¶876¶5¶77¶" ; X2 = "1 bob¶richard¶How are you today¶5" ]; Quicksort(X1) & "¶¶¶" & Quicksort(X2) )//End Let() It returned: 2 5 8 77 78 387 876 69879 How are you today richard 1 bob 5 What I want to be able to do is sort data that is stored in a Variable, without storing it in a field. I found many sorting options that use the ValueList from a field. My issue with doing it this way is that 1: it's slower, and 2: it removes duplicate entries. Any ideas on how I can adjust Quicksort() to fix this? Thanks! Brian Hightower
August 27, 200619 yr That Mode demo was meant for dealing with numbers. As I recall, the sorting of those numbers was made possible by using the GetAsNumber() function within the ValuesLessThanOrEqual() and ValuesGreaterThan() CFs. By removing the GetAsNumber() part, you should be able to sort text.
Create an account or sign in to comment