QuestionsArray compare or sort two values and swap values each other
mmWebetutorial Staff asked 8 months ago



$flag = true;


while ( $flag )


$flag = false;

for( $j=0;  $j < count($array_attr)-1; $j++)


//echo $j;

if ( $array_attr[$j][“label”] > $array_attr[$j+1][“label”] )


$temp = $array_attr[$j];

//swap the two between each other

$array_attr[$j] = $array_attr[$j+1];


$flag = true; //show that a swap occurred




//sorting end

Your Answer
Enter email and password to comment or answer
Not the answer you are looking for? Browse other questions tagged or ask your own question.