a = arrayNew(1); month = createDate(year(now()), month(now()), 1); for (i = 1; i LTE 6; i = i + 1) { s = structNew(); s.letter = chr(65 + randRange(0, 25)); s.date = dateAdd("d", randRange(0, 27), month); arrayAppend(a, s); }

Comparators

Here we're doing some sorting of complex values using Java Comparators. An array of six structs is created, each with a random letter and random date inside. That's what's dumped in the first column. The rest of the columns show the same array sorted in different ways.

On Railo 3.0.0.002 and below only, no sorting happens. There is a bug (which has been resolved) that prevents Collections.sort from making changes to the array being sorted. Later versions of Railo do not have this problem.

Randomized Letter (CFML) Letter (closure) Date DESC (class)
Collections.sort(variables.a, new ReverseDateKeyComparator()) Collections.sort(variables.a, {o1, o2 -> o1.letter.compareTo(o2.letter) } as Comparator)

The raw array of structs