Cfquery returntype Struct ordered or unordered?

So if you use a return type of struct, the order will work in the same way you would expect a query object to work. If I set the order by clause in my SQL statement, it will be honored in the result set structure.

Regarding your question to whether it’s an ordered struct or LinkedHashMap: I’m not certain as the class type of the return is a Lucee class called QueryStruct. It would appear it’s some extension to a LinkedHashMap/Collection possibly.

Consider the following code which can be run here → TryCF.com

<cfscript>
users = queryNew(
    "id, firstname", "integer, varchar",
    [
        { "id":1, "firstname": "Han" },
        { "id":2, "firstname": "Chewie" }
    ]
);
subUsers = queryExecute(
    "select * from users order by firstname",
    {},
    { dbtype="query", returntype="struct", columnkey="id" }
);

dump( subUsers );
dump( subUsers.getClass() );
</cfscript>