Skip 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 "sorted" records

Featured Replies

Is there a way to sort data while preserving actual sorting order.

e.g. sorting by SALESMAN while already sorted by INVOICE will give me records sorted by SALESMAN then by INVOICE for each salesman.

I know I can specify both sort order in a single "Sort Records[]" script step but i want to sort them using two script steps. I probably have to get rid of the "Restore" in the Sort statement.

I have built a huge sorter script that sort on a specific column base on its name (switch-case), and a string tokenizer that gives me in reverse order all names specified on a comma separated list, but I suspect new Sort script steps to sort as if data were not actually sorted.

Thanks

I'll take a stab at it. What if you have 2 fields and 3 scripts.

The 2 fields are Salesman# and Invoice#.

The first script changes the numeric value of Salesman#.

The second script changes the numberic value of Invoice#.

The third script sort the records by the numeric values of Saleman# and Invoice#.

This way you can have one sort script and still change the sort order.

Just a thought.

  • Author

I'm not sure I understand what you mean.

Are you suggesting to set a "foo" field to salesman# then sort using "foo" then set "foo" field to invoice# then sort again using "foo"? Isn't that what i'm trying to achieve sorting by "invoice#" then "salesman#" expecting invoice# to remain sorted (within salesman block)

If you suggesting to set foo1 to salesman# then foo2 to invoice#... then foo-n to ... then finally sort by foo1, foo2, ..., foo-n it MIGHT work even if it takes more memory. Also we should take care of datatype and either "format" them prior to store them in text field 9 -> "0000009", November 1st -> "20071101" or store them in foonum1, footext1, foodate1, foonum2, footex2, foodate2, ... A lot of extra processing but...

There is a lot of possible fields to sort by and I dont want to rely on FM dialog to set which one I want records to be sorted by. I prefer setting "salesman#, invoice#, itemunitprice, itemname" in a text field or a ScriptParameter then parse it.

I'm not quite sure what your referring to with "foo" field. What I'm saying is, there is no way to sort records while saving a previous sort order without some way of marking the original sort order.

The fields I was referring to was two number fields. Their sole purpose is to establish and save the sort order. We can call these sort1 and sort2. The way it works is, you sort your records in the first order you want. A script then populates the sort1 field, by putting in a number representing the numerical number. First Record = 1, Tenth record = 10, etc. Then you sort your records in the second order you want. Then do the same for the sort2 field. Once both fields are populated a single script can be used to sort your records based on the two sort fields. What's nice about this is, You only need one sort script. What you decide to sort with stays open.

  • Author

okay okay... what I mean by "preserving" the actual sort is to sort by a new column while item having the same value on the new column are still sorted by the previously order.

Till FM is probably using QuickSort algorithm, it's prolly impossible.

  • Author

It's me again...

So you suggest something like that

fidx1: Number

fidx2: Number

fidxn: Number

fval1: Text = case(fidx1=1; salesman; fidx1=2; invoice#; ...; "")

fval2: Text = case(fidx2=1; salesman; fidx2=2; invoice#; ...; "")

fvaln: Text = case(fidxn=1; salesman; fidxn=2; invoice#; ...; "")

Sort Records[Restore; No dialog][fval1 ASC, fval2 ASC fvaln ASC]

Your getting the idea. You'll find you'll have more flexibility by sorting your records based on fields that can change without changing the critical information for that record. For example: fidx1 could = 1,2,50 or anyother number. Whatever that number is, it will only change the sort order, not you records critical information.

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Search

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.