Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Sorting a block of data by Line.

Featured Replies

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

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.

Here is another technique that might be interesting.
  • 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

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.

  • Author

Oh Yes! That worked!!

Thanks!

Brian Hightower

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.