I have a an AttributeValue DataObject, with has_one relation to the Attribute it is a value of. When listing the attribute values I want them sorted by a "Weight" parameter set in the Attribute. So I have a method in the controller for my class applying the attributes named SortedAttributeValues(). But I can not get it working. Can ofc make my own sorting algorithm but would rather figure out how to use the built in.
$this->ProductAttributeValues()->sort('ProductAttribute->Weight');
// Turned out the sorting method does a $obj->$column when comparing.
//$this->ProductAttributeValues()->sort('ProductAttribute.Weight');
I'm very grateful if someone has some ideas to throw my way.
EDIT: Simplified the problem.