original_string: public static function sort(array $array, string $field, string $direction = 'ASC', $method = SORT_REGULAR) : array
       {
           if (count($array) > 0) {
  
               // Create the helper array
               foreach ($array as $key => $row) {
                   $helper[$key] = function_exists('mb_strtolower') ? mb_strtolower(Arr::get($row, $field)) : strtolower(Arr::get($row, $field));
               }
  
               // Sort
               if($method === SORT_NATURAL) {
                   natsort($helper);
                   ($direction === 'DESC') and $helper = array_reverse($helper);
               } elseif ($direction == 'DESC') {
                   arsort($helper, $method);
               } else {
                   asort($helper, $method);
               }
  
               // Rebuild the original array
               foreach ($helper as $key => $val) {
                   $result[$key] = $array[$key];
               }
  
               // Return result array
               return $result;
           }
       }
code: public static function sort(array $array, string $field, string $direction = 'ASC', $method = SORT_REGULAR) : array
       {
           if (count($array) > 0) {
  
               // Create the helper array
               foreach ($array as $key => $row) {
                   $helper[$key] = function_exists('mb_strtolower') ? mb_strtolower(Arr::get($row, $field)) : strtolower(Arr::get($row, $field));
               }
  
               // Sort
               if($method === SORT_NATURAL) {
                   natsort($helper);
                   ($direction === 'DESC') and $helper = array_reverse($helper);
               } elseif ($direction == 'DESC') {
                   arsort($helper, $method);
               } else {
                   asort($helper, $method);
               }
  
               // Rebuild the original array
               foreach ($helper as $key => $val) {
                   $result[$key] = $array[$key];
               }
  
               // Return result array
               return $result;
           }
       }
code_tokens: public static function sort ( array $ array , string $ field , string $ direction = 'ASC' , $ method = SORT_REGULAR ) : array { if ( count ( $ array ) > 0 ) { // Create the helper array foreach ( $ array as $ key => $ row ) { $ helper [ $ key ] = function_exists ( 'mb_strtolower' ) ? mb_strtolower ( Arr :: get ( $ row , $ field ) ) : strtolower ( Arr :: get ( $ row , $ field ) ) ; } // Sort if ( $ method === SORT_NATURAL ) { natsort ( $ helper ) ; ( $ direction === 'DESC' ) and $ helper = array_reverse ( $ helper ) ; } elseif ( $ direction == 'DESC' ) { arsort ( $ helper , $ method ) ; } else { asort ( $ helper , $ method ) ; } // Rebuild the original array foreach ( $ helper as $ key => $ val ) { $ result [ $ key ] = $ array [ $ key ] ; } // Return result array return $ result ; } }
docstring: Sorts a multi-dimensional array by a certain column
  
  $new_array = Arr::sort($old_array, 'title');
  
  @param  array  $array     The source array
  @param  string $field     The name of the column
  @param  string $direction Order type DESC (descending) or ASC (ascending)
  @param  const  $method    A PHP sort method flag or 'natural' for natural sorting, which is not supported in PHP by sort flags
  @return array
docstring_tokens: Sorts a multi - dimensional array by a certain column