BP_Document::array_sort_by_column( $array,  $column, int $direction = SORT_DESC )

Sort by column.

Description

Parameters

$array

(Required)

$column

(Required)

$direction

(Optional)

Default value: SORT_DESC

Source

File: bp-document/classes/class-bp-document.php

1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
public static function array_sort_by_column( $array, $column, $direction = SORT_DESC ) {
 
    $new_array = json_decode( json_encode( $array ), true );
 
    if ( 'date_created' === $column ) {
        $mapping_arr = array_map( 'strtotime', array_column( $new_array, $column ) );
        array_multisort( $mapping_arr, $direction );
    } else {
        $reference_array = array();
 
        foreach ( $array as $key => $row ) {
            $reference_array[ $key ] = $row[ $column ];
        }
 
        array_multisort( $reference_array, $direction, $array );
    }
 
}

Changelog

Changelog
Version Description
BuddyBoss 1.4.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.