Answer to Question #26252 in AJAX | JavaScript | HTML | PHP for shahbaz

Question #26252
how we can sort and asort digit without using default function of php....?
1
Expert's answer
2013-03-15T09:09:29-0400
To perform this task, we canuse the following method: compare each element of the array, and the
larger of the two compared move to the right side, thus sorting array in
ascending order. Below is the code, which is based on this method.
<?php
$input= array(0.1,77,0.5,6.2,6,2,4);
for($i=0;$i<count($input)-1;$i++)
for($c=0;$c<count($input)-1;$c++){
if($input[$c]>$input[$c+1]){
$t=$input[$c];
$input[$c]=$input[$c+1];
$input[$c+1]=$t;
}
}
print_r($input);
?>

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS