Sort a related products view based on product features
If you want to display those product first that matches the current product features, include all those fields in view accordingly and then apply views_query_alter function to override the order and sort according to current product.

For example, If you want to sort according to product color taxonomy term, Include the field (Products referenced) Commerce Product: color (desc) in sort criteria of view. Then write following code in module file

function MYMODULE_views_query_alter(&amp;$view, &amp;$query) {
  // condition for current view
  if($view-&gt;name == 'related_products') {
    //Get current node product color tid &amp; override order query to sort according to that id
    $node = node_load(arg(1));
    $product_id = $node-&gt;field_product_reference[LANGUAGE_NONE]['0']['product_id'];
    $product = commerce_product_load($product_id);
    $query-&gt;orderby[0]['field'] = "commerce_product_field_data_field_product_reference__field_data_field_product_color.field_product_color_tid = '".$product-&gt;field_product_color[LANGUAGE_NONE]['0']['tid']."'";
  }
}


Let me know if you face any query regarding this.

Thanks!