DCOM-134: [GH-213] Added sort option for array collection #434

doctrinebot opened this Issue Nov 11, 2012 · 2 comments

2 participants


Jira issue originally created by user @beberlei:

This issue is created automatically through a Github pull request on behalf of andrewtarry:

Url: #213


I have added a sorter class and sortBy method for the ArrayCollection class. It gives the option to reorder the ArrayCollection after someone has gotten it from the database, e.g. from a relationship. It takes an array of method names to sort by in order to priority and it takes an optional boolean to set the order to ascending. Here is an example:

$arraycollection->sortBy(array('getName()', 'getAddress()'));

It will recursively loop the collection change the order. Each time it will look to see if the previous matching option is the same as for the previous element and then store those elements in list to be reordered.

Once it has looped all the elements it will reorder the elements it has matched and if there is another option to reorder by it will loop only the elements it matched last time so it is not looping the whole array each time.


Comment created by @ocramius:

Can't change because of BC, and the performance impact is too high


Issue was closed with resolution "Won't Fix"

@doctrinebot doctrinebot added the Bug label Dec 6, 2015
@beberlei beberlei was assigned by doctrinebot Dec 6, 2015
@doctrinebot doctrinebot closed this Dec 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment