Sort attachment macro numerically
Asked by Nikki Hailey:

We have a list of attachments that are all numbered according to a structure within another program. When we set the Attachments macro to sort by name, it sorts it by the leading character instead of the entire leading number, so instead of having a list of 1, 2, 3, 4, etc... we have 1, 10, 11, 12, 2, 3. There has to be a way around this, but I cannot find it.

Thanks

![Confluence Attachment Numeric Sort.jpg](/t5/image/serverpage/image-id/155286i2557CC29BD399218/image-size/large?v=v2&px=999 "Confluence Attachment Numeric Sort.jpg")


Answers:
author: Davin Studer
body: Unfortunately, file names are considered strings so they are sorted alphabetically. Normally when I have files that need to be sorted numerically by date I name them thusly ... YYYYMMDD_MyFile.xlsx. That way they will sort correctly.

comments: author: Nikki Hailey
body: What if you wanted to sort them numerically, not by date? The date in our file names is the same in each file, we need them to sort numerically. I stopped at 12 when I saw what was happening, but we have many more that need to be added. I guess I can just add them as links, but then I will have to go back and manually add links whenever someone adds a new file, which defeats the purpose of having a macro to sort them for us. (I know it's not your fault, just venting!)


author: Shannon S
body: Hi Nikki,

What Davin mentioned is correct. Confluence sorts the files alphabetically and not numerically, and so the best recommendation is to name your files as in Davin's example.

I wanted to follow-up with you because we have had a few open feature requests about this, such as

* [CONFCLOUD-35534](https://jira.atlassian.com/browse/CONFCLOUD-35534) Tables sort numbers alphabetically not numerically (closed)
* [CONFCLOUD-55384](https://jira.atlassian.com/browse/CONFCLOUD-55384) Children display macro sort numbers wrongly (open)

Note the first request has been closed, but the 2nd one is relevant, even though it mentions the Children display macro. Confluence sorts all content this way.

As [@Natalie Paramonova \[Stiltsoft\]](/t5/user/viewprofilepage/user-id/1779341) recommended, if you don't want to rename your attachment names, you need to install a Marketplace app to introduce this feature to Confluence.

I hope that helps, but let me know if you have any questions.

Take care,

Shannon


author: Natalie Paramonova [Stiltsoft]
body: Hi [@Nikki Hailey](/t5/user/viewprofilepage/user-id/3460030) , as a workaround, you can use the [Table Filter](https://docs.stiltsoft.com/display/TFAC/How+to+use+Table+Filter+macro) macro that provides a number of [options for better table viewing](https://docs.stiltsoft.com/display/TFAC/Sorting%2C+freezing+and+other+table+viewing+options), including sorting (you can even sort by multiple columns if needed).

![2021-08-10_10h47_09.png](https://community.atlassian.com/t5/image/serverpage/image-id/155366iF3D69D88DE40E392/image-size/large?v=v2&px=999 "2021-08-10_10h47_09.png")

The result:

![2021-08-10_10h47_35.png](https://community.atlassian.com/t5/image/serverpage/image-id/155367i3FE7B149525EBB06/image-size/large?v=v2&px=999 "2021-08-10_10h47_35.png")

comments: author: Nikki Hailey
body: Thank you, but we don't have the bundle that includes the Table Filter macro.


Tags: cloud

confluence-cloud