.................
New member
Hi, trying to write my own function for put number array in ascending or descending order
I know they they is PHP function which does that but i wont to write my own one..
this is what I have wrote but its just keeping looping i have try this on 650000 records . it does stop can any one tell me what's wrong with this function.
public function sort_array(){
$temp = 0;
for( $i=0; $i<sizeof($this->record_two); $i++ ){
for( $j=sizeof($this->record_two)-1; $j > $i; $j--){
if( $this->record_two[$j-1] > $this->record_two[$j] ){
$temp = $this->record_two[$j-1];
$this->record_two[$j-1] = $this->record_two[$j];
$this->record_two[$j] = $temp;
//break;
}
}
}
}
Thank you
I like to use my own sorting function. Don't like to use built in sorting function. Please if you can give some information what is problem with my function.
I know they they is PHP function which does that but i wont to write my own one..
this is what I have wrote but its just keeping looping i have try this on 650000 records . it does stop can any one tell me what's wrong with this function.
public function sort_array(){
$temp = 0;
for( $i=0; $i<sizeof($this->record_two); $i++ ){
for( $j=sizeof($this->record_two)-1; $j > $i; $j--){
if( $this->record_two[$j-1] > $this->record_two[$j] ){
$temp = $this->record_two[$j-1];
$this->record_two[$j-1] = $this->record_two[$j];
$this->record_two[$j] = $temp;
//break;
}
}
}
}
Thank you
I like to use my own sorting function. Don't like to use built in sorting function. Please if you can give some information what is problem with my function.