Query on custom drupal 7 field
Try something like (supposing "weight" module is used and weights are stored in the "weight_weights" table - to be adapted for another module ) :

$query = db_select('node', 'n');
$query-&gt;fields('n', array('nid', 'type'));
$query-&gt;join('weight_weights', 'w', 'n.nid = w.entity_id');//join can not be chained
$query-&gt;condition('n.type', 'portfolio', '=');
$query -&gt;orderBy('w.weight', 'ASC');