# Sort Array Content Alphabetically?

**URL:** <https://community.tulip.co/t/sort-array-content-alphabetically/9440>\
**Category:** Support, Troubleshooting, & Help\
**Tags:** array, sort\
**Created:** [October 4, 2023, 4:21am UTC](https://community.tulip.co/t/sort-array-content-alphabetically/9440 "2023-10-04T04:21:13Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmlowden](https://sea2.discourse-cdn.com/flex020/user_avatar/community.tulip.co/jmlowden/32/8645_2.png) [@jmlowden](https://community.tulip.co/u/jmlowden)\
**Post date:** [October 4, 2023, 4:21am UTC](https://community.tulip.co/t/sort-array-content-alphabetically/9440/1 "2023-10-04T04:21:13Z")

</div>

Any suggestions for how to automatically sort the contents of an array so that the elements appear in alphabetical (or alphanumerical) order?

---

<div class="post-metadata">

**Author:** ![John](https://sea2.discourse-cdn.com/flex020/user_avatar/community.tulip.co/john/32/4971_2.png) [@John](https://community.tulip.co/u/John)\
**Post date:** [October 4, 2023, 12:56pm UTC](https://community.tulip.co/t/sort-array-content-alphabetically/9440/2 "2023-10-04T12:56:24Z")

</div>

I’d be super curious if anyone has built this using the trigger editor in Tulip. This suggestion sounds like a perfect use for custom widgets + ChatGPT.

---

<div class="post-metadata">

**Author:** ![Niklas](https://sea2.discourse-cdn.com/flex020/user_avatar/community.tulip.co/niklas/32/6188_2.png) [@Niklas](https://community.tulip.co/u/Niklas)\
**Post date:** [November 14, 2023, 1:34pm UTC](https://community.tulip.co/t/sort-array-content-alphabetically/9440/3 "2023-11-14T13:34:29Z")

</div>

Has a solution or workaround been found for sorting the contents of an array? (alphabetically or alphanumerically)

---

<div class="post-metadata">

**Author:** ![dsun](https://avatars.discourse-cdn.com/v4/letter/d/13edae/32.png) [@dsun](https://community.tulip.co/u/dsun)\
**Post date:** [November 14, 2023, 4:28pm UTC](https://community.tulip.co/t/sort-array-content-alphabetically/9440/4 "2023-11-14T16:28:06Z")

</div>

Hi Niklas,

Are you able to access an SQL database + SQL Connector? If so, you can write a simple SQL Query to take in an array joined into a string, and then output an array after sorting.

In the code below, I am also getting rid of duplicate entries.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/agilemfg/original/2X/2/2fc0f75c6dd5b442405b92fe13af11b55a57b155.png)

---

<div class="post-metadata">

**Author:** ![ASharp-J](https://sea2.discourse-cdn.com/flex020/user_avatar/community.tulip.co/asharp-j/32/3820_2.png) [@ASharp-J](https://community.tulip.co/u/ASharp-J)\
**Post date:** [November 15, 2023, 1:41pm UTC](https://community.tulip.co/t/sort-array-content-alphabetically/9440/5 "2023-11-15T13:41:10Z")

</div>

I had the same challenge and resorted to triggers performing sorting by swapping elements in the array (which is silly). If we are to stick to standard functions and not program widgets to perform sorting maybe it isn’t such a big deal for the product team to add a “Sort array” action to the list of array functions. What is the Tulip product opinion on this?

![image](https://us1.discourse-cdn.com/flex020/uploads/agilemfg/original/2X/1/1b6825c4500d5f4c46456a4c0a19545923b90b81.png)

---

<div class="post-metadata">

**Author:** ![OliverGnepper](https://avatars.discourse-cdn.com/v4/letter/o/bbe5ce/32.png) [@OliverGnepper](https://community.tulip.co/u/OliverGnepper)\
**Post date:** [June 26, 2024, 12:03pm UTC](https://community.tulip.co/t/sort-array-content-alphabetically/9440/6 "2024-06-26T12:03:15Z")

</div>

Hi, is there an update regarding this topic?

---

<div class="post-metadata">

**Author:** ![Beth](https://sea2.discourse-cdn.com/flex020/user_avatar/community.tulip.co/beth/32/5987_2.png) [@Beth](https://community.tulip.co/u/Beth)\
**Post date:** [June 26, 2024, 1:02pm UTC](https://community.tulip.co/t/sort-array-content-alphabetically/9440/7 "2024-06-26T13:02:00Z")

</div>

Hi @OliverGnepper and others!

We actually talked about this in Office Hours on June 13th with @jmlowden and have a workaround option. Similar to what @dsun proposed, if you are pulling data into your array from a Tulip Table, you can use the query to sort alphabetically, and then when you are taking aggregation and pulling into an array, the array will be populated alphabetically.

So basically, if you can get your data sorted ahead of time, you can pull it into your array alphabetically.

However, I know it would be easiest if there was an array function that allowed you to do this natively, so I will see if this is something on the Product Team’s radar as well!

---

<div class="post-metadata">

**Author:** ![OliverGnepper](https://avatars.discourse-cdn.com/v4/letter/o/bbe5ce/32.png) [@OliverGnepper](https://community.tulip.co/u/OliverGnepper)\
**Post date:** [June 26, 2024, 1:15pm UTC](https://community.tulip.co/t/sort-array-content-alphabetically/9440/8 "2024-06-26T13:15:27Z")

</div>

Hi @Beth,

thanks for providing the updated information. The described workaround covers only the use case where the data is consumed from a third party system. I don’t see how this workaround covers use cases where the data comes from user inputs.

---

<div class="post-metadata">

**Author:** ![jakerigos](https://sea2.discourse-cdn.com/flex020/user_avatar/community.tulip.co/jakerigos/32/6898_2.png) [@jakerigos](https://community.tulip.co/u/jakerigos)\
**Post date:** [June 26, 2024, 1:36pm UTC](https://community.tulip.co/t/sort-array-content-alphabetically/9440/9 "2024-06-26T13:36:50Z")

</div>

Hi @OliverGnepper,

The point about sorting arrays is definitely heard and understood.

Sincerely,

Jake

---

<div class="post-metadata">

**Author:** ![jmlowden](https://sea2.discourse-cdn.com/flex020/user_avatar/community.tulip.co/jmlowden/32/8645_2.png) [@jmlowden](https://community.tulip.co/u/jmlowden)\
**Post date:** [July 16, 2024, 5:26pm UTC](https://community.tulip.co/t/sort-array-content-alphabetically/9440/10 "2024-07-16T17:26:27Z")

</div>

You could pass the user input data into a “scratch pad” table, linked by a common session or step or event ID column value, and then use the query/sort/aggregation to get the unique values in your preferrred sort order, then pass them back to the app.

---

<div class="post-metadata">

**Author:** ![OliverGnepper](https://avatars.discourse-cdn.com/v4/letter/o/bbe5ce/32.png) [@OliverGnepper](https://community.tulip.co/u/OliverGnepper)\
**Post date:** [July 17, 2024, 8:09am UTC](https://community.tulip.co/t/sort-array-content-alphabetically/9440/11 "2024-07-17T08:09:57Z")

</div>

Thanks for your advise. I already hat this option in mind, but since multiple stations might use this function simultaneously several questions (e.g. information separation, information access, failure management, cleanup, …) arise which would be covered best by an in-app solution.

---

<div class="post-metadata">

**Author:** ![jmlowden](https://sea2.discourse-cdn.com/flex020/user_avatar/community.tulip.co/jmlowden/32/8645_2.png) [@jmlowden](https://community.tulip.co/u/jmlowden)\
**Post date:** [July 18, 2024, 3:32pm UTC](https://community.tulip.co/t/sort-array-content-alphabetically/9440/12 "2024-07-18T15:32:06Z")

</div>

You could resolve that concern by tagging the table records with a unique “session ID” that is generated when the app is started - for ours we make this a string including the app name/version, datetime, user username, etc. We use that routinely for grouping table data generated within a single app session, to allow for querying those records as a group (i.e. to review/correct data generated within the session).

Also, if there are records created across multiple apps/sessions but related to a common “event” (or “batch”), you can have another “event ID” tag to group those in queries.

---

<div class="post-metadata">

**Author:** ![OliverGnepper](https://avatars.discourse-cdn.com/v4/letter/o/bbe5ce/32.png) [@OliverGnepper](https://community.tulip.co/u/OliverGnepper)\
**Post date:** [July 19, 2024, 7:12am UTC](https://community.tulip.co/t/sort-array-content-alphabetically/9440/13 "2024-07-19T07:12:48Z")

</div>

This suggestions solely covers the information separation topic. The stored information is still accessible for unauthorized persons, the in app failure management doesn’t work and a separate cleanup process is also necessary.

You might call me narrow minded, but I tend to omit a function if there is only a half-baked tinkered solution.

---

<div class="post-metadata">

**Author:** ![thorsten.langner](https://avatars.discourse-cdn.com/v4/letter/t/4bbf92/32.png) [@thorsten.langner](https://community.tulip.co/u/thorsten.langner)\
**Post date:** [July 19, 2024, 7:51am UTC](https://community.tulip.co/t/sort-array-content-alphabetically/9440/14 "2024-07-19T07:51:32Z")

</div>

I am actually using a custom widget to eliminate duplicates and sort a list.

```javascript
let processedList;

getValue("Text_List_Input", (internalVariable) => {
  processedList = [...new Set(internalVariable)].sort();
  setValue("Text_List_Input", processedList);
  fireEvent("Text_List_Processed");
});

```

![image](https://us1.discourse-cdn.com/flex020/uploads/agilemfg/original/2X/4/4ccc559a558f9c89b6d50b4b90872b65e12b8ba9.png)

It will change the input itself immediately

Feel free to only change it to only sort the list.  
But keep in Mind: This way of sorting will separate all capital letters… e.g.:

- Apple
- Bus
- Car
- angle
- busy

and not:

- angle
- Apple
- Bus
- busy
- Car

The Event is optional and not relevant for the widget to work.

---

<div class="post-metadata">

**Author:** ![bharatreddyv](https://avatars.discourse-cdn.com/v4/letter/b/848f3c/32.png) [@bharatreddyv](https://community.tulip.co/u/bharatreddyv)\
**Post date:** [October 16, 2024, 10:35am UTC](https://community.tulip.co/t/sort-array-content-alphabetically/9440/15 "2024-10-16T10:35:48Z")

</div>

If “The point about sorting arrays is definitely heard and understood.” wondering why “Sort” function in “Arrays” is still not available? What product feature selection process for the next build/release/roadmap is stopping from giving this universal feature… instead of recommendations to go around looking for alternatives or building custom widgets!

---

<div class="post-metadata">

**Author:** ![OlgaStroilova](https://sea2.discourse-cdn.com/flex020/user_avatar/community.tulip.co/olgastroilova/32/7199_2.png) [@OlgaStroilova](https://community.tulip.co/u/OlgaStroilova)\
**Post date:** [October 18, 2024, 3:26pm UTC](https://community.tulip.co/t/sort-array-content-alphabetically/9440/16 "2024-10-18T15:26:37Z")

</div>

Hi @bharatreddyv , pleasure to meet you on the Community forum

I’m a new Product Manager at Tulip, taking over the team responsible for logic - including triggers, arrays, automations, etc.

Acknowledge your really valid feedback here about the difficulty of interacting with arrays today. Agree that some of the ideas mentioned here are a bit of a workaround. I’d personally love to improve the experience of working with arrays, and would be happy to share our thought process for identifying and prioritizing roadmap items.

quick tl;dr - the next item we’re working on in the area of “logic” is a step into logic reusability, **creating a new feature called Functions,** which we’re hoping to release in the next few months, and then iterate on. We’re also the team responsible for Automations and are planning a few improvements there around version & run history storage and publishing.

Would you be open to a quick call to introduce myself, chat through any questions you may have around this, and also the separate thread on global variables? If so, I’ll reach out over email with some times.

Appreciate your presence and input!

- Olga

---

<div class="post-metadata">

**Author:** ![jmlowden](https://sea2.discourse-cdn.com/flex020/user_avatar/community.tulip.co/jmlowden/32/8645_2.png) [@jmlowden](https://community.tulip.co/u/jmlowden)\
**Post date:** [March 24, 2025, 9:00pm UTC](https://community.tulip.co/t/sort-array-content-alphabetically/9440/17 "2025-03-24T21:00:22Z")

</div>

It would be great if the new array functions work could help sort Object Lists in addition to standard arrays.

---

<div class="post-metadata">

**Author:** ![jmlowden](https://sea2.discourse-cdn.com/flex020/user_avatar/community.tulip.co/jmlowden/32/8645_2.png) [@jmlowden](https://community.tulip.co/u/jmlowden)\
**Post date:** [March 24, 2025, 9:03pm UTC](https://community.tulip.co/t/sort-array-content-alphabetically/9440/18 "2025-03-24T21:03:26Z")

</div>

A variation on this approach that I recently used is to source a multiselect input widget from a table query aggregation - this puts the selection options in the correct order, but the resulting array is ordered according to how the user checked the boxes. To re-sort the resulting multiselect array, I have a trigger leveraging that array and overwriting it with the aggregation result against the same table, sorted in the correct order, with the query catching all matching every record whose field value IS IN the multiselect results. It works very tidily and rapidly in the case where the inputs are already coming from a table source.

---

<div class="post-metadata">

**Author:** ![dsantos](https://avatars.discourse-cdn.com/v4/letter/d/c57346/32.png) [@dsantos](https://community.tulip.co/u/dsantos)\
**Post date:** [April 11, 2025, 3:49pm UTC](https://community.tulip.co/t/sort-array-content-alphabetically/9440/19 "2025-04-11T15:49:21Z")

</div>

Hey James and all,  
Thanks again for mentioning this variation for taking a multiselect input widget and using queries/aggregations to rearrange the result alphabetically. As I mentioned on an office hours call I have been working on the same functionality but within a connector using SQL. Prior to what screenshot you see below is an action to take the variable from a multiselect and turn it TOPLAINTEXT() using an expression. Then I feed that into a connector function that you can see in the screenshot below. Afterwards, in the app, take the resulting object and maptotext list \> arrays \> join to string. Then you will have one resulting string

 ![Screenshot 2025-04-11 at 11.46.24 AM](https://us1.discourse-cdn.com/flex020/uploads/agilemfg/original/2X/e/eae5bfa6b8c188561f9687f7783026a27946f5af.png)
