Magento - Unable to set order of collection

EAV collections work with attributes, the sorting method is a little different here as well

$componentQuantityCollection->addAttributeToSort('sku', 'ASC');

For non-EAV collections use one of the following methods

$kitCollection->getSelect()->order('related_sku DESC');
$kitCollection->setOrder('related_sku', 'DESC');

You can add sort order like this:

$kitCollection->getSelect()->order('related_sku DESC');

More information: http://www.magentocommerce.com/wiki/1_-_installation_and_configuration/using_collections_in_magento

Hope can help you.


To expand on the other answers here, $kitCollection->getSelect()->order('column DESC') works fine, but you can't add more than one column. For instance, $kitCollection->getSelect()->order('column DESC, column2 ASC') will error. This is because of the work that Magento does to escape the column names. To get around this, you can use a Zend_Db_Expr like so:

$kitCollection->getSelect()->order(new Zend_Db_Expr('related_sku DESC, column2 ASC'));