Munchie Posted August 24, 2006 Posted August 24, 2006 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
Ender Posted August 25, 2006 Posted August 25, 2006 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.
comment Posted August 25, 2006 Posted August 25, 2006 Here is another technique that might be interesting.
Munchie Posted August 27, 2006 Author Posted August 27, 2006 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
Ender Posted August 27, 2006 Posted August 27, 2006 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.
Munchie Posted August 27, 2006 Author Posted August 27, 2006 Oh Yes! That worked!! Thanks! Brian Hightower
Recommended Posts
This topic is 6664 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now