Q:

Json Object Sorting in Php

I m not professional and i have a problem.
I call assists created with json object in database.
This code is calling in the order of creation, but I want to sort the number from the large to the smallest. I tried many things but couldn't.
I need your helps. Thanks
// add action to check for table item
add_action('gdlr_print_item_selector', 'gdlr_league_table', 10, 2);
function gdlr_league_table($type, $settings = array()){
    if($type == 'gol-krali'){
        gdlr_print_league($settings);
    }
}

//table item
function gdlr_print_league($settings){
    // query league table
    $args['post_type'] = 'player';
    $args['posts_per_page'] = (empty($settings['num-fetch']))? '555': $settings['num-fetch'];

    $query = new WP_Query( $args );

    // getting table array
    while($query->have_posts()){ $query->the_post();
        $player_val = gdlr_lms_decode_preventslashes(get_post_meta(get_the_ID(), 'gdlr-soccer-player-settings', true));
        $assists = empty($player_val)? array(): json_decode($player_val, true); 
        $table[get_the_title()]['p'] = ($assists);  
    }
    echo '<div class="gdlr-item gdlr-league-table-item" ' . $item_id . $margin_style . ' >';
    if(empty($settings['style']) || $settings['style'] == 'full'){
        gdlr_print_league_table($table);
    }
    echo '</div>';
}

// table
function gdlr_print_league_table($player){
    echo '<table class="gdlr-league-table" >';
?>
<tr class="gdlr-table-second-head gdlr-title-font">
    <th class="gdlr-table-pos"><?php echo __('Sıra', 'gdlr-soccer'); ?></th>
    <th class="gdlr-table-team"><?php echo __('Oyuncu', 'gdlr-soccer'); ?></th>
    <th class="gdlr-table-p">Asist</th>
</tr>
<?php
    $count = 1;
    foreach($player as $player_name => $score ){
?>
<tr>
    <td class="gdlr-table-pos"><?php echo $count; ?></td>
    <td class="gdlr-table-team"><?php echo $player_name ?></td>
    <td class="gdlr-table-p"><?php echo $score['p']['player-stats']['assists']; ?></td>
</tr>
<?php
        $count++;
    }
    echo '</table>';
}

A:

You can sort the $payer array with uasort just before your loop:
uasort($player, function($a, $b) {
    return $b['p']['player-stats']['assists']-$a['p']['player-stats']['assists'];
});
foreach($player as $player_name => $score ){

