Thanks
This is what i have

<?php 
function msort($array, $id="order") {
	echo($array);
        $temp_array = array();
        while(count($array)>0) {
            $lowest_id = 0;
            $index=0;
            foreach ($array as $item) {
                if (isset($item[$id]) && $array[$lowest_id][$id]) {
                    if ($item[$id]<$array[$lowest_id][$id]) {
                        $lowest_id = $index;
                    }
                }
                $index++;
            }
            $temp_array[] = $array[$lowest_id];
            $array = array_merge(array_slice($array, 0,$lowest_id), array_slice($array, $lowest_id+1));
        }
        return $temp_array;
}

$array_Test = array();
$newArray = array();
$array_Test['TestID'][1] ="1";
$array_Test['Name'][1] = "Joe";
$array_Test['order'][1] ="3";
 
$array_Test['TestID'][2] ="2";
$array_Test['Name'][2] = "Ana";
$array_Test['order'][2] ="1";
 
$array_Test['TestID'][3] ="3";
$array_Test['Name'][3] = "Mara";
$array_Test['order'][3] ="2";

$newArray = msort($array_Test);
echo($newArray['Name'][1]); // Should be Ana
echo(" ");
echo($array_Test['Name'][1]);// Should be Joe
?>

For some rason echo($newArray[1]); is not returning anything

Recommended Answers

All 3 Replies

What is the msort function supposed to do, frankly I can't tell.

I have updated my code to look like

Ok What i am i have is a list of teams with thereamount of there provblems.
i am creating my original list by

<?php
    $array_OriginalOrder = array();
    $i=0;
    while ($i <= $count_Team-1):
        // GET TEAM 
        $TeamID = $array_Team['TeamID'][$i];
        // Get Total 
        getAllTOTALByTeam($TeamID);
        // PopulateAttay
        $array_OriginalOrder['TeamID'][$i] 					= $TeamID;
        $array_OriginalOrder['count_getAllTOTALByTeam'][$i] = $count_getAllTOTALByTeam;

        echo($array_OriginalOrder['TeamID'][$i]);
        echo(" "); 
        echo($array_OriginalOrder['count_getAllTOTALByTeam'][$i]);
        echo("<br /> "); 
    $i++;
    endwhile;

?>

OUT PUT

1 4
2 0
3 1
4 0
5 16
6 5
7 0
8 2
9 0
10 0
11 0
12 0
13 0
14 8
15 0
16 5

What i need to get is
2 0
4 0
7 0
9 0
10 0
11 0
12 0
13 0
15 0
3 1
8 2
1 4
6 5
16 5
5 16

i for some rason i cant get this to work for me Thanks

A) what is this function doing getAllTOTALByTeam($TeamID); B) This is obviously not all of your code, you're using arrays that have clearly been defined before but you're just giving us a snippet.
C) Use uasort
D) No, I'm not going to help you/show you/give you code on how to use uasort, use the documentation

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.