title: php- find duplicate and sort by array property
body: <p>I have a large associative array of products. i want to check if there are <strong>duplicate</strong> products then get product with <strong>low price</strong>. </p>
  
  <p>I can use <em>array_unique</em> and <em>array_count_values</em> to find duplicate records, but I don't know how to handle sorting part. </p>
  
  <p>array properties:</p>
  
  <ul>
  <li>product_id (unique)</li>
  <li>title</li>
  <li>price</li>
  </ul>
  
  <p><strong>sample data</strong></p>
  
  <pre>
  
  Array
  (
      [0] => Array
          (
              [product_id] => 1111
              [title] => Product 1
              [price] => 140
          )
  
      [1] => Array
          (
              [product_id] => 2222
              [title] => Product 2
              [price] => 66
          )
  
      [2] => Array
          (
              [product_id] => 1111
              [title] => Product 1 A
              [price] => 123
          )
  
      [3] => Array
          (
              [product_id] => 3333
              [title] => Product 3
              [price] => 37.4
          )
  
      [4] => Array
          (
              [product_id] => 4444
              [title] => Product 4
              [price] => 10.5
          )
  
  )
  
  </pre>
  
  <p><br><br></p>
  
  <p>product 1 is duplicated so there will be one record against product 1 and with low price should be kept.</p>
  
  <p><strong>output should be like</strong></p>
  
  <pre>
  
  Array
  (
      [0] => Array
          (
              [product_id] => 1111
              [title] => Product 1
              [price] => 123
          )
  
      [1] => Array
          (
              [product_id] => 2222
              [title] => Product 2
              [price] => 66
          )  
  
      [2] => Array
          (
              [product_id] => 3333
              [title] => Product 3
              [price] => 37.4
          )
  
      [3] => Array
          (
              [product_id] => 4444
              [title] => Product 4
              [price] => 10.5
          )
  
  )
  
  </pre>