I have an entity \"container\" with this property
/**
* @ORM\\OneToMany(targetEntity=\"BizTV\\ContentManagementBundle\\Entity\\Content\", mappedBy=\"container\"
You can also sort ArrayCollection
by Criteria
property orderBy
like so:
getCollection();
// convert normal array to array collection object
if(\is_array(collection)) {
$collection = new ArrayCollection(collection);
}
// order collection items by position property
$orderBy = (Criteria::create())->orderBy([
'position' => Criteria::ASC,
]);
// return sorter SomeCollectionItem array
return $collection->matching($orderBy)->toArray();
}
}
?>