使用array_multisort()排序问题和警告数组大小不一致

As you can see the 2d array is as following:

Array ( [0] => Array ( [0] => Prishtina [1] => Bregu i Diellit [2] => 7 ) 
    [1] => Array ( [0] => Prishtina [1] => Tasligje [2] => 4 ) 
    [2] => Array ( [0] => Prishtina [1] => Bregu i Diellit [2] => 4 ) 
    [3] => Array ( [0] => Prishtina [1] => Bregu i Diellit [2] => 3 ) 
    [4] => Array ( [0] => Prishtina [1] => Bregu i Diellit [2] => 9 ) 
    [5] => Array ( [0] => Prishtina [1] => Lakrishte [2] => 4 ) 
    [6] => Array ( [0] => Prishtina [1] => Lakrishte [2] => 6 ) 
    [7] => Array ( [0] => Prishtina [1] => Lakrishte [2] => 1 ) 
    [8] => Array ( [0] => Prishtina [1] => Ulpiana [2] => 3 ) 
    [9] => Array ( [0] => Prishtina [1] => Ulpiana [2] => 6 ) 
    [10] => Array ( [0] => Prishtina [1] => Ulpiana [2] => 5 ) 
    [11] => Array ( [0] => Prishtina [1] => Ulpiana [2] => 8 ) 
    [12] => Array ( [0] => Prishtina [1] => Ulpiana [2] => 4 ) 
    [13] => Array ( [0] => Prishtina [1] => Ulpiana [2] => 8 ) 
    [14] => Array ( [0] => Prishtina [1] => Velania [2] => 2 ) 
    [15] => Array ( [0] => Prishtina [1] => Velania [2] => 5 ) 
    [16] => Array ( [0] => Prishtina [1] => Velania [2] => 1 ) 
    [17] => Array ( [0] => Prishtina [1] => Dragodan [2] => 9 ) 
    [18] => Array ( [0] => Prishtina [1] => Dragodan [2] => 7 ) 
    [19] => Array ( [0] => Prishtina [1] => Dragodan [2] => 10 ) 
    [20] => Array ( [0] => Prishtina [1] => Velania [2] => 11 ) 
    [21] => Array ( [0] => Mitrovica [1] => Qender [2] => 5 ) 
    [22] => Array ( [0] => Mitrovica [1] => Qender [2] => 3 ) 
    [23] => Array ( [0] => Mitrovica [1] => Tavnik [2] => 6 ) 
    [24] => Array ( [0] => Mitrovica [1] => Tavnik [2] => 9 ) 
    [25] => Array ( [0] => Mitrovica [1] => Bair [2] => 10 ) 
    [26] => Array ( [0] => Mitrovica [1] => Bair [2] => 12 ) 
    [27] => Array ( [0] => ) ) 

I am trying to sort by the 3rd column with the following code:

foreach ($final_array as $roww){
    $sort_column[]= $roww[2];   // 2 = your example
    array_multisort($sort_column, $final_array);
}

However when im printing:

for ($row = 0; $row < count($final_array); $row++)
{
    foreach($final_array[$row] as $key => $value)
        {
            echo $value;
        }
        echo "<br/>";
 }

WHen i am printing, it sorts and it prints the array as sorted by the 3rd column, however it is bringing me these warnings

Warning: array_multisort() [function.array-multisort]: Array sizes are inconsistent in   C:\xampp\htdocs\test\test.php on line 35
 Notice: Undefined offset: 2 in C:\xampp\htdocs\test\test.php on line 34

I am not sure why is this happening, it doesnt make sense to me, everything is working however i need these warnings out!!

This is a warning as there is an undefined reference to your array at index 27. The warning is saying that you are trying to use that value but it doesn't exist.

Take another look at your array

array_multisort() if used to sort many arrays at once echoes warning, if all of the arrays chosen to perform multisort on are different in a matter of size:

$arr = array(
    'UK' => array(
        'John' => 'Toyota',
        'Alice' => 'Opel',
        'Evan' => 'Fiat',
        'Gregory' => 'Mitsubishi'
    ),
    'Germany' => array(
        'Bruno' => 'Opel',
        'Andreas' => 'Mercedes',
        'Klaus' => 'Porsche',
    )
);

See? Number of elements in both arrays differ. So, array_multisort will try to sort these arrays in the same way, even if options are different:

array_multisort(
    $arr['Germany'], SORT_ASC, SORT_NATURAL,
    $arr['UK'], SORT_DESC, SORT_NUMERIC
    );

This will print a warning like: Warning: array_multisort(): Array sizes are inconsistent in (...)

Another condition that will throw an "array sizes are inconsistent" occurs when the same key name or names are used in two unrelated multi-dimensional arrays. You can still use the same key names if you clear the key name prior to setting columns in the second multi-dimensional array. If doing this is discouraged, I'd be interested in knowing why.