[Rt-devel] Sorting an RT collection

Jesse Vincent jesse at bestpractical.com
Fri Apr 28 10:58:11 EDT 2006


Stephen Turner wrote:
> Hello,
> 
> I have a need to sort a collection (of tickets) based on some criterion
> that is not a simple table attribute/column. I'm thinking I can populate
> a Tickets object in the normal way and then call a new method to sort
> the internal array that holds the retrieved database rows.
> 
> Where I'm getting confused is: SearchBuilder maintains rows in an array
> $self->{'items'}, but Tickets_Overlay seems to maintain a second array
> $self->{'items_array'} (in the ItemsArrayRef method).
> 
> My questions are:
> 
> - Why two arrays?

So, there's an awful lot of *cough* legacy code in there. I _think_ that
it has to do with only wanting the ItemsArrayRef to contain items that
had passed an ACL check. And my _guess_ is that the code in
Tickets_Overlay predated a refactoring of SearchBuilder that made this
code more accessible.

> - Can my goal be achieved as simply as I think (by sorting the
> appropriate arrays) or is there more to it?

The one caveat is that if you have a search that's more than one "page"
long, you're going to be sorting within a page.

> - Is this (sorting by not-a-table-column) done anywhere currently within
> RT?

To my knowledge, it's not yet. It feels like a feature that would be a
natural addition to SearchBuilder, if the Tickets_Overlay code doesn't
block the way.


> Thanks,
> Steve

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 191 bytes
Desc: OpenPGP digital signature
Url : http://lists.bestpractical.com/pipermail/rt-devel/attachments/20060428/ae9a8cde/signature.pgp


More information about the Rt-devel mailing list