How do I display the data in descending order?

1

I would like to know how I can display the data in descending order through the score field, in that code it is displaying r, and I'd like to display from major to small :

<?php$pasta="C:\Users\Vinicius\Desktop\Vinicius\SS Oficial by Vinicius\scriptfiles\Scores"; 
        $classificar = "Score";  

        $jogadores= -1; 
        $dadosjogador = array(); 
        $handlepasta = opendir($pasta); 


        while(($nickname  = readdir($handlepasta)) !== false) { 
                if(($nickname !=".") && ($nickname  !="..") && ($nickname != "index.htm") && ($nickname !="info")) { 
            $jogadores++; 
                        $contaaberta    = parse_ini_file($pasta ."/". $nickname); 
                        $nickname      = substr($nickname, 0,strlen($nickname)-4); 
                        $dadosjogador[$jogadores] =  array($contaaberta[$classificar] ,$nickname ); 
                } 
        } 



        array_multisort ($dadosjogador, $dadosjogador); 



        foreach ($dadosjogador as $jogador_atual) { 
                echo "<b>Jogador</b>:  ".$jogador_atual[1]."    |    <b>Score</b>:  ".$jogador_atual[0]."  <br>"; 
        } 
?>
    
asked by anonymous 24.09.2016 / 23:19

2 answers

2

Solution:

array_multisort ($dadosjogador, SORT_DESC); 
    
24.09.2016 / 23:54
0

In this specific case usort with a function would also solve:

usort($array, function($a,$b){
    return $b[0] > $a[0];
});

being $b[0] and $a[0] is the position of the values, then having the option to place the column that should be sorted.

    
25.09.2016 / 00:27