Here, there is such an array
$material_weights = array( 0 => array( 'nid' => 54545, 'weight' => 0 ), 1 => array( 'nid' => 545, ), 2 => array( 'nid' => 225, 'weight' => 4 ), 3 => array( 'nid' => 6, 'weight' => 1 ), 4=> array( 'nid' => 6, ), 5 => array( 'nid' => 6, 'weight' => 3 ), ) It is necessary to sort it by the 'weight' field, in ascending order, so that all elements that do not have the 'weight' field are put to the end. But it is better to retain their original sequence, that is, 1 and 6 elements should be inserted at the end, but 1 should still go before 6