# structKeyArray()

**URL:** <https://dev.lucee.org/t/structkeyarray/14537>\
**Category:** language\
**Created:** [December 5, 2024, 6:47am UTC](https://dev.lucee.org/t/structkeyarray/14537 "2024-12-05T06:47:00Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gavin\_Baumanis](https://dev.lucee.org/user_avatar/dev.lucee.org/gavin_baumanis/32/267_2.png) [@Gavin\_Baumanis](https://dev.lucee.org/u/Gavin_Baumanis)\
**Post date:** [December 5, 2024, 6:47am UTC](https://dev.lucee.org/t/structkeyarray/14537/1 "2024-12-05T06:47:00Z")

</div>

The Lucee documentation states the following for `structKeyArray()`:

> For unsorted structs, Adobe returns a text sorted Array of keys, for performance reasons, Lucee simply returns the raw sort order

This statement is NOT correct.

Using the built-in cftry portion of the [Lucee Docs](https://docs.lucee.org/reference/functions/structkeyarray.html)

Shows that the returned array is indeed, sorted.

 ![image](https://dev.lucee.org/uploads/default/original/2X/1/1087b237b14a894e313d336bd2047c77297c728b.png)

(Lucee 4.5, 5.4 and 6 - all return a sorted array.)

Either the documentation is wrong - or Lucee does not correctly implement its own spec.

---

<div class="post-metadata">

**Author:** ![andreas](https://dev.lucee.org/user_avatar/dev.lucee.org/andreas/32/3352_2.png) [@andreas](https://dev.lucee.org/u/andreas)\
**Post date:** [December 5, 2024, 7:27am UTC](https://dev.lucee.org/t/structkeyarray/14537/3 "2024-12-05T07:27:40Z")

</div>

Maybe some insights  
[https://luceeserver.atlassian.net/browse/LDEV-4725](https://luceeserver.atlassian.net/browse/LDEV-4725)

---

<div class="post-metadata">

**Author:** ![BK\_BK](https://dev.lucee.org/user_avatar/dev.lucee.org/bk_bk/32/3450_2.png) [@BK\_BK](https://dev.lucee.org/u/BK_BK)\
**Post date:** [December 6, 2024, 10:03am UTC](https://dev.lucee.org/t/structkeyarray/14537/4 "2024-12-06T10:03:48Z")

</div>

[deleted]

---

<div class="post-metadata">

**Author:** ![kenricashe](https://dev.lucee.org/user_avatar/dev.lucee.org/kenricashe/32/3476_2.png) [@kenricashe](https://dev.lucee.org/u/kenricashe)\
**Post date:** [December 7, 2024, 5:22pm UTC](https://dev.lucee.org/t/structkeyarray/14537/5 "2024-12-07T17:22:21Z")

</div>

Indeed, and adding to the confusion in that doc page is the term “unsorted structs”, which should be “unordered structs”.

---

<div class="post-metadata">

**Author:** ![Zackster](https://dev.lucee.org/user_avatar/dev.lucee.org/zackster/32/3484_2.png) [@Zackster](https://dev.lucee.org/u/Zackster)\
**Post date:** [April 12, 2025, 8:53am UTC](https://dev.lucee.org/t/structkeyarray/14537/6 "2025-04-12T08:53:36Z")

</div>

keep in mind, CFDUMP can be misleading, as it sorts on display

try `serializeJson()` or looping over the collection

---

<div class="post-metadata">

**Author:** ![Gavin\_Baumanis](https://dev.lucee.org/user_avatar/dev.lucee.org/gavin_baumanis/32/267_2.png) [@Gavin\_Baumanis](https://dev.lucee.org/u/Gavin_Baumanis)\
**Post date:** [April 16, 2025, 10:07pm UTC](https://dev.lucee.org/t/structkeyarray/14537/7 "2025-04-16T22:07:09Z")

</div>

“AAAhhhh”  
I didn’t know that cfdump automatically “sorts”.

IS there any value in me logging a ticket to change it?  
To me - cfdump shouldn’t do anything like this - at least not implicitly.

---

<div class="post-metadata">

**Author:** ![Zackster](https://dev.lucee.org/user_avatar/dev.lucee.org/zackster/32/3484_2.png) [@Zackster](https://dev.lucee.org/u/Zackster)\
**Post date:** [April 16, 2025, 10:39pm UTC](https://dev.lucee.org/t/structkeyarray/14537/8 "2025-04-16T22:39:12Z")

</div>

> <https://github.com/lucee/Lucee/pull/2377>
>
> https://luceeserver.atlassian.net/browse/LDEV-4876

but i’m thinking of maybe just annotating the display (sorted for display) like we do for ordered structs, as it’s nice being sorted after all, there is no guaranteed sort order otherwise and it will potentially change randomly
