ACF returns a text sorted StructKeyList() / cfloop collection for unordered structs

Description

Environment

None

Attachments

3

Activity

Andreas R 
5 December 2024 at 07:33

I wouldn't change anything in the cfdump() to reflect it as output in ACF. That would create confusion, as shown in

https://dev.lucee.org/t/structkeyarray/14537/2

 

Igal Sapir 
31 May 2024 at 15:36

I would hate to slow down Lucee in order to be more compatible with ACF

One could always call sort() explicitly if that’s a requirement, e.g.

someStruct.keyArray().sort()

Zac Spitzer 
31 May 2024 at 12:25

Added a usage notes to the docs

https://docs.lucee.org/reference/functions/structkeylist.html#usage-notes

https://docs.lucee.org/reference/functions/structkeyarray.html#usage-notes

After some internal discussion, we probably intend to leave this as is, we will consider adjusting the output of cfdump to reflect the Lucee behaviour (i.e. not sort) with perhaps the option to sort in js?

https://github.com/lucee/Lucee/blob/6.1/core/src/main/java/lucee/runtime/type/util/StructUtil.java#L175

Zac Spitzer 
31 May 2024 at 10:09
(edited)

ACF is sorting the keys, which adds the overhead of sorting

<cfscript> normal = { D:1, B:1, C:1 }; writedump( var=normal, label="unordered" ); </cfscript> <cfloop collection="#normal#" item="k"> <cfoutput>#k#,</cfoutput> </cfloop> <cfscript> ordered = [ D=1, B=1, C=1 ]; writedump( var=ordered, label="ordered struct" ); </cfscript> <cfloop collection="#ordered#" item="k"> <cfoutput>#k#,</cfoutput> </cfloop>

 

https://trycf.com/gist/6aac481b7317a8581a31043b89cf29f0/acf2023?theme=monokai

Pothys - MitrahSoft 
28 May 2024 at 13:13

I checked this ticket and it is still a issue with Lucee version 6.1.0.162-SNAPSHOT.

Details

Assignee

Reporter

Priority

New Issue warning screen

Before you create a new Issue, please post to the mailing list first https://dev.lucee.org

Once the issue has been verified, one of the Lucee team will ask you to file an issue

Created 12 October 2023 at 11:54
Updated 5 December 2024 at 07:33