# Sorting data from two fields

**URL:** <https://community.glideapps.com/t/sorting-data-from-two-fields/76762>\
**Category:** Ask for Help\
**Created:** [October 2, 2024, 2:59pm UTC](https://community.glideapps.com/t/sorting-data-from-two-fields/76762 "2024-10-02T14:59:48Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bleu.Elefant](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/bleu.elefant/32/40086_2.png) [@Bleu.Elefant](https://community.glideapps.com/u/Bleu.Elefant)\
**Post date:** [October 2, 2024, 2:59pm UTC](https://community.glideapps.com/t/sorting-data-from-two-fields/76762/1 "2024-10-02T14:59:49Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Eric\_Penn](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/eric_penn/32/73888_2.png) [@Eric\_Penn](https://community.glideapps.com/u/Eric_Penn)\
**Post date:** [October 2, 2024, 3:18pm UTC](https://community.glideapps.com/t/sorting-data-from-two-fields/76762/2 "2024-10-02T15:18:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [October 3, 2024, 10:50am UTC](https://community.glideapps.com/t/sorting-data-from-two-fields/76762/3 "2024-10-03T10:50:52Z")

</div>

Use a JavaScript column:

 ![CleanShot 2024-10-03 at 18.49.58@2x](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/9/7/979e3409ece8d977128b2121509661a2726b3491.png)

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

```

---

<div class="post-metadata">

**Author:** ![Bleu.Elefant](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/bleu.elefant/32/40086_2.png) [@Bleu.Elefant](https://community.glideapps.com/u/Bleu.Elefant)\
**Post date:** [October 4, 2024, 3:25am UTC](https://community.glideapps.com/t/sorting-data-from-two-fields/76762/4 "2024-10-04T03:25:36Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Bleu.Elefant](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/bleu.elefant/32/40086_2.png) [@Bleu.Elefant](https://community.glideapps.com/u/Bleu.Elefant)\
**Post date:** [October 4, 2024, 3:29am UTC](https://community.glideapps.com/t/sorting-data-from-two-fields/76762/5 "2024-10-04T03:29:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/system/32/53398_2.png) [@system](https://community.glideapps.com/u/system)\
**Post date:** [October 11, 2024, 3:30am UTC](https://community.glideapps.com/t/sorting-data-from-two-fields/76762/6 "2024-10-11T03:30:00Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
