Sorting data from two fields

I have two fields which I wish to concatenate in a third field. I am well aware of using the Template function for joining text.

What I would like to be able to do as well, is to join text from the two fields however would like to do them in alphabetical order.

For example, if I have a field with ‘Oscar Jones’ in one field and ‘Nigel Greer’ in the second, I would like ‘Nigel’ to be listed first and ‘Oscar’ listed second.

On the front end if you add a collection to the screen you should be able to sort the collection by the template column… if you’re trying to sort it in the data editor then I don’t think there’s any easy way to do that

1 Like

Use a JavaScript column:

let arr = [];
arr.push(p1);
arr.push(p2);
return arr.sort().join(', ');
5 Likes

Maybe I didn’t explain it correctly. I didn’t want the columns sorted. What I wanted was the names, when joined to be sorted alphabetically so that regardless of which name was in either column, the result would always place names in alphabetical order.

I think I solved it with the following Excel formula.
IF(A1<A2,CONCATENATE(A1," & “,A2,CONCATENATE(A2,” & ",A1)

Thanks for javascript formula, I can use that elsewhere.

Apologies. Your method worked. I type in field names instead of selecting from drop-down. Duh!