I create code for CSV format , but you must replace
return $a['plain_products_name'] < $b['plain_products_name'] ? -1: 1;
with
return $a['_pickup_date'] < $b['_pickup_date'] ? -1: 1;
Here is unmodified code
// Sort by product name
// Format CSV
// option "Fill order columns for" = ALL rows
class Woe_Sort_By_Product_Name_CSV {
var $session_key = "woe_temp_rows_csv";
function __construct() {
//add settings
add_action("woe_settings_above_buttons", array($this,"draw_options") );
// start SESSION
add_filter("woe_settings_validate_defaults", function($settings) {
if( !empty($settings[ 'sort_by_products' ]) ) {
@session_start();
//stop default output for rows
add_action("woe_csv_header_filter",array($this,"init_session_data"),10,2);
add_action("woe_csv_output_filter",array($this,"record_csv_rows"),10,2);
add_action("woe_csv_print_footer",array($this,"sort_rows"),10,2);
}
return $settings;
});
}
// 1
function draw_options($settings){
$selected = !empty($settings[ 'sort_by_products' ]) ? 'checked': '';
echo '<input type=hidden name="settings[sort_by_products]" value="0">
<input type=checkbox name="settings[sort_by_products]" value="1" '. $selected .'>
<span class="wc-oe-header">Sort by products, Format CSV</span>';
}
// 2 init storage
function init_session_data($data) {
$_SESSION[$this->session_key] = array();
return $data;
}
//3 down't export rows
function record_csv_rows($data,$obj) {
$_SESSION[$this->session_key][] = $data;
return false;
}
//4 sort and print
function sort_rows($handle,$formatter) {
usort($_SESSION[$this->session_key], function($a,$b) {
return $a['plain_products_name'] < $b['plain_products_name'] ? -1: 1;
});
foreach($_SESSION[$this->session_key] as $pos=>$data)
fputcsv($handle,$data, $formatter->delimiter, $formatter->enclosure);
}
}
new Woe_Sort_By_Product_Name_CSV();