adding all children node flag count to sort parent
Is it possible to have a hidden field on parent node value for which updates as per the flag counter on referenced node changes.In that case it will be easier to build custom query or even if you use views you can sort by the hidden field  value.

Updated:


  
  Child node 1 has a node reference to Parent Node.
  Keep flag count as hidden field on parent content type
  The time flag is updated on Child node, you can grab all parent nodes on the updated child node.
  Change the hidden field value on parent node from hidden field value to +1.
  


Code that can be used to update parent node field
 - you will have all parent node id in child node object, grab the ids.
 - Use the following code to update the parent fields.

  $node = node_load($nid);
  $node-&gt;field_flag_count['und'][0]['value'] += 1;
  field_attach_presave('node', $node);
  field_attach_update('node', $node);



  This will save lot more node save processing and unnecessary node
  revisions


SO this way the total flag count will all be present on parent node and sorting will be lot more easier that way!.