# Sort array by a number

**URL:** <https://community.make.com/t/sort-array-by-a-number/7135>\
**Category:** Questions\
**Tags:** arrays\
**Created:** [January 24, 2023, 10:04am UTC](https://community.make.com/t/sort-array-by-a-number/7135 "2023-01-24T10:04:17Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![CarlaK](https://avatars.discourse-cdn.com/v4/letter/c/858c86/32.png) [@CarlaK](https://community.make.com/u/CarlaK)\
**Post date:** [January 24, 2023, 10:04am UTC](https://community.make.com/t/sort-array-by-a-number/7135/1 "2023-01-24T10:04:17Z")

</div>

Hi Guys

Is there a way to get the sort function to treat the key (which is a string) as a number?

It’s currently sorting it to 1, 11, 12, 2, 3, 4, etc.

I’ve gone ahead and changed the Monday column to text instead of number and changed them all to 01, 02, etc. But is there a cleaner option within Make that doesn’t involve iterating through the whole array and adding everything to a new array (could be expensive operations wise)?

![image](https://europe1.discourse-cdn.com/flex013/uploads/make/original/2X/e/e9162d900c3e6e1d83f2716d3bfac84c79dbb6fe.png)

---

<div class="post-metadata">

**Author:** ![Florian](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/florian/32/11118_2.png) [@Florian](https://community.make.com/u/Florian)\
**Post date:** [January 25, 2023, 9:30am UTC](https://community.make.com/t/sort-array-by-a-number/7135/2 "2023-01-25T09:30:52Z")

</div>

Hi @CarlaK ,

With the available functions available with Make, the only way I think to sort an array of number in a string format is by iterating them and parse them as a number to sort them. As you mention it’s not really efficient and could cost a lot of operations.  
Another way would be to use a custom module including a Javascript function to do the job.

I did develop that module for you , feel free to install it and test it.  
[Custom module installation](https://make.com/en/hq/app-invitation/b444741427d9674df9de24f6e96ebdb2)

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/make/original/2X/9/96d3f9ffbd2316a24523e46b40d28fc62f4f353b.jpeg)  
The blueprint if you want test it with a model :  
[sort string numbers.json](https://community.make.com/uploads/short-url/rkUNQQJX6RD3DCLl3JrYVWkXn5c.json) (4.5 KB)

Please mark this post the solution if it works for you, thank you.

---

<div class="post-metadata">

**Author:** ![andyoneil](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/andyoneil/32/126_2.png) [@andyoneil](https://community.make.com/u/andyoneil)\
**Post date:** [August 7, 2023, 9:21pm UTC](https://community.make.com/t/sort-array-by-a-number/7135/3 "2023-08-07T21:21:32Z")

</div>

@Florian did you unpublish the custom module? I can’t seem to use it after installing.  
Thank you!

---

<div class="post-metadata">

**Author:** ![Florian](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/florian/32/11118_2.png) [@Florian](https://community.make.com/u/Florian)\
**Post date:** [October 24, 2023, 6:36am UTC](https://community.make.com/t/sort-array-by-a-number/7135/4 "2023-10-24T06:36:04Z")

</div>

Hello Andy, the module is still online and works, use that link to install it : [https://www.make.com/en/hq/app-invitation/b444741427d9674df9de24f6e96ebdb2](https://www.make.com/en/hq/app-invitation/b444741427d9674df9de24f6e96ebdb2)

---

<div class="post-metadata">

**Author:** ![Nick\_B](https://avatars.discourse-cdn.com/v4/letter/n/cab0a1/32.png) [@Nick\_B](https://community.make.com/u/Nick_B)\
**Post date:** [November 6, 2023, 9:35pm UTC](https://community.make.com/t/sort-array-by-a-number/7135/5 "2023-11-06T21:35:10Z")

</div>

WORKAROUND:

 ![Screen Shot 2023-11-07 at 7.34.30 am](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/7/7/776e62c437076c85d3963e7b5e2946a3ad386a50.png)  
I solved this by parsing the strings as numbers, then adding to a Number Array in Datastore. Then sorting the Array in Datastore in ASC or DES.

---

<div class="post-metadata">

**Author:** ![andyoneil](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/andyoneil/32/126_2.png) [@andyoneil](https://community.make.com/u/andyoneil)\
**Post date:** [November 8, 2023, 8:33pm UTC](https://community.make.com/t/sort-array-by-a-number/7135/6 "2023-11-08T20:33:43Z")

</div>

Hey there, I’m seeing this when trying to install:  
 ![image](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/b/c/bc92192b5153e90f778db52fd9381f14f84c6b41.png)

When I install, I don’t see any modules in Make.

I’d love to use this if there’s a fix.

Andy

---

<div class="post-metadata">

**Author:** ![Make\_Bot](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/make_bot/32/14661_2.png) [@Make\_Bot](https://community.make.com/u/Make_Bot)\
**Post date:** [November 23, 2023, 8:07am UTC](https://community.make.com/t/sort-array-by-a-number/7135/7 "2023-11-23T08:07:17Z")

</div>


