• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Structures in Arrays + sorting

New Here ,
Jan 25, 2007 Jan 25, 2007

Copy link to clipboard

Copied

Hi,
i want to do some sorting on a structure where the items will get rearranged like arraysort does, and not give me the a sorted list of keys.

So I did an array that contains structures. I also wanted to use structures because i wanted to use names instead of numbers for referencing my data.

so here's my code.


<CFSET myArray = arrayNew(1)>

<CFSET myStruct = structNew()>
<CFSET myStruct.item = "1">
<CFSET arrayAppend(myArray, myStruct)>

<CFSET myStruct = structNew()>
<CFSET myStruct.item = "2">
<CFSET arrayAppend(myArray, myStruct)>

<CFSET arraySort( myArray.item, "numeric", "ASC")>


how can i make this work?
TOPICS
Advanced techniques

Views

193

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jan 25, 2007 Jan 25, 2007

Copy link to clipboard

Copied

LATEST
You could store the data as a query instead of an array of structures. That would give you access to CF's native query sorting.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation