Sort a Joined List using a secondary joined list as sort keys

Finally found a reason to have a play with this one :smiley:

Not sure how useful this will be for others, but @Jeff_Hager might find it of interest.

It accepts two joined lists, and will sort the values in the first list using the values in the second list as sort keys, and will return the sorted list as a single string with the delimiters stripped out.

I had a very specific use case for this, which was to transform a table like this:

into this:

It takes an optional delimiter as a 3rd parameter. In this case I used || in my joined lists as the source data (the dates) contains commas.

Update: This has been moved to GitHub, and a few more options added. Link has been updated.



1 Like

Hi, any chance this stopped working or am doing this wrong?

The list is not changed at all - in fact no matter what I type in the Joined List - sort keys it returns the original list

I haven’t touched it for a long time. It might be that the hebrew text is tripping it up, although I wouldn’t think so.
Do any of the rows in your “JoinedDataTable” contain commas? That would certainly break it, if they did.

I actually have a “more advanced” version that I use now, that has a few more options. This is the one that I use mostly now. Perhaps you can try this one?

Update: oh, are you using the one on Replit? I don’t maintain that one anymore, I should take it down. I moved all my code columns to GitHub a long time ago. I’ll update the original post.


still getting the same list.

see the sorting number of step down yet it still appears last

Any chance you can share some sample data with me, and I’ll see if I can debug it?

sure :slight_smile:
Template column:

<td style="width:40%">cell4_1</td>
<td style="width:18%">cell3_1</td>
<td style="width:19%">cell2_1</td>
<td style="width22:%">cell1_1</td>

EX Name Reps Sets Comments Sort
Barbell Hip Thrust 8-10 4 1
Knee banded frog thrust 12-15 3 מייד אחרי התרגיל הקודם 2
Split Squat 10 3 כל אימון להתחיל מרגל אחרת. להוסיף משקל 3
Barbell Sumo Deadlift 8-10 3 חובה לצלם - להתחיל משקל נמוך 4
Bent Knee Side Bridge Hip Abduction 25 2 אם קל לשים משקולת על הירך 6
Lying Leg-Hip Raise 20 1 8
V-up 10 2 7
Step-down 12-15 3 5

hmm, seems to work fine for me…

can you screen shot the lists?

I’d share the whole thing, but unfortunately you can’t share apps that use Experimental Code columns.

Template for the table rows
Screen Shot 2022-01-29 at 11.04.43 PM

Joined list of table rows
Screen Shot 2022-01-29 at 11.04.58 PM

Joined list of the Sort column
Screen Shot 2022-01-29 at 11.05.15 PM

thats a mystery im doing the exact same here:

and i get this

could you remove the ex column and share it

There is a bunch of other junk in the app. It’s just one I use from time to time to experiment with things. So you can ignore all that - just look for the table called “Lin”

OHH never mind I got it!!
I didnt use a comma in the TD joined list becuse HTML dosent need it but the sorting does.



Yeah, that’s a bit of a trap. A delimiter is required for it to work. I generally use a double-pipe ||, because every now and then there might be a comma in the data (dates, for example).


New Problem:
If the Sort is empty the EX column returns blank instead of the original order.
and if I use a template to replace with 1 for example the sort is DESC

What is the desired behaviour if the sort row is empty?
Should the row be ignored, or default to zero, or?

I have case where the user doesn’t need to sort the list because he is ok with the order he created the rows. also sometimes he would use sort only on several rows.
the app behavior is if the sort is empty the list is displayed in the sheet order, and if some rows have a value they appear under the blank sorting rows.
I would like the joined list to do the same.

added example: some rows with sort

hmm, you’ll probably need to create two template columns for the table rows - one with delimiters and one without. Then use an if-then-else column to decide which one to use in the table. If the sort is empty, use the one without delimiters and plug it straight into the table. Otherwise use the one with delimiters and pass it through the experimental code column first.

or do that :rofl:

1 Like

can I fork this and just change the default parameter?