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

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


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];
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)!!



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.


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.


you need two columns:

  • Joined List 1 with A, B, C from the relation
  • Joined List 2 with 3, 1, 2 from the relation

Create another one:

  • Other\Code\JavaScript and use the below:
    JavaScript code:
var FirtstSortColumn = p1.split(",");
var SecondColumn = p2.split(",");

var arr = [];

for (var i = 0; i < p2.split(",").length; i++) {

function sortFunction(a, b) {
    if (a[0] === b[0]) {
        return 0;
    else {
        return (a[0] < b[0]) ? -1 : 1;
var arrfinal = [];

for (var i = 0; i < p2.split(",").length; i++) {
return arrfinal.toString();

p1: Joined List 2
p2: Joined List 1
p3: leave empty