title: Coldfusion 8: Array of structs to struct of structs
body: <p>I've got an array items[]
  Each item in items[] is a struct.
  item has keys id, date, value (i.e., item.id, item.date, item.value)</p>
  
  <p>I want to use StructSort to sort the item collection by a date</p>
  
  <p>Is this the best way to do it in ColdFusion 8:</p>
  
  <pre><code>&lt;cfset allStructs = StructNew()&gt;
  &lt;cfloop array = #items# index = "item"&gt;
      &lt;cfset allStructs[item.id] = item&gt;
      &lt;cfset unixtime = DateDiff("s", CreateDate(1970,1,1), item.date)&gt;
      &lt;cfset allStructs[item.id].unixtime = unixtime&gt;
  &lt;/cfloop&gt;
  &lt;cfset allStructs = StructSort(allStructs, "numeric", "desc", "unixtime")&gt;
  </code></pre>
  
  <p>It's going to be dreadfully slow</p>