Sort a relation

Hey Gliders. Can you help me Sort a relation?

I need this because I want to fire a webhook with some data. But it needs to sort the relational data.

Any thoughts


In the sheets
A has 3
B has 1
C has 2

I want to the webhook to sent
B,C,A

So to paraphrase, you want to create a joined list of column values via a relation, but have the list sorted by the values in a separate column, yes?

I don’t think this is possible using just native Glide computed columns.
But I have an Experimental Code column that will get you very close, and would be easy enough to modify to get what you want.

The modification you would need to make would be in Line 27 of function.js, just including a comma as a delimiter in the return value, ie:

var joined = sorted.join(',');

With that modification, you could use it as follows:

  • Create two joined list columns via your relation (one for A,B,C and the other for 3,2,1)
  • Use the Experimental Code column, passing it the two joined list columns
3 Likes

Hola

This is another easy solution by using the @Darren_Murphy’s idea: using the JavaScript plugin.

Taking advantage of this plugin supports 3 parameters (I hope someday it can handle at least 5 and can return an array’s values :nerd_face:), we can have this simple code:

const Values= [p1, p2, p3];
Values.sort();
return Values[0] + "," + Values[1] + "," + Values[2] ;

Of course, you must have 3 columns in the same sheet to get it (3 Simple Value columns can help you)!!

Saludos!

3 Likes

I’m not sure that this actually gives the desired result, although I may have misunderstood what was being asked. Wouldn’t be the first time :crazy_face:

Well, you are not alone!!

I’m thinking frequently that my english is causing me problems to understand some questions (or people don’t want to say all truth at the beginning). :innocent:

1 Like

Not related to this thread, but I wanted to respond to this. While there are only three parameters available in the javascript plugin, you can still pass many more. In the image below, I passed in a P1, P2, and P3 parameter, but each parameter was filled with multiple other pieces of information using a comma delimiter in between. I was then able to split them into 12 variables to use throughout the rest of the code.

image

Kind of the same thing if you wanted an array out of the javascript. Just return a string of delimited text and use a Split Text column to turn it into an array.

2 Likes