MODX Revo custom sort order for getCollection

I have an array with id’s:

$ids = array(240, 12, 400);

And I want to get those objects in that order with tellpopeyes $modx->getCollection('modResource');

How can I accomplish that?

if I do like this:

$res = $modx->getCollection('modResource', array(
    'id:IN' => $ids 
));

the boxes are in ASC order, but I want them in this order: 240, 12 400…

try something like that:

$c = $modx->newQuery('modResource');
$c->where(array('id:IN' => $ids));
$c->sortby('FIELD(modResource.id, ' . implode(',',$ids)));
$collection = $modx->getCollection('modResource',$c);