def reorder_coords(coords, sample_ids, order):
 try:
  result = array([coords[sample_ids.index(sample_id)] for sample_id in order])
 except ValueError:
  raise ValueError(('Unknown sample ID: %s' % sample_id))
 return result

def reorder_coords ( coords , sample_ids , order ) : try : result = array ( [ coords [ sample_ids . index ( sample_id ) ] for sample_id in order ] ) except ValueError : raise ValueError ( ( 'Unknown sample ID: %s' % sample_id ) ) return result
arrange the rows in coords to correspond to order note: order is the master list here -- if a sample id is not included in order .