Sort
Introduction #
Sort
process helps you to sort data based on columns. It works like the SORT BY in SQL Statement. The input array contains key=>value
where key
will be column name and the value
is the direction of sort.
Examples #
Simple sorting #
<?php
use \koolreport\processes\Sort;
class MyReport extends \koolreport\KoolReport
{
public function setup()
{
...
->pipe(new Sort(array(
"age"=>"asc",
"name"=>"desc"
));
...
}
}
Advanced sorting with function #
If you need sort differently rather than simple desc
or asc
, you can set your own comparison function.
<?php
use \koolreport\processes\Sort;
class MyReport extends \koolreport\KoolReport
{
public function setup()
{
...
->pipe(new Sort(array(
"age"=>function($a,$b){
return $a<$b;
},
));
...
}
}
Get started with KoolReport
KoolReport will help you to construct good php data report by gathering your data from multiple sources, transforming them into valuable insights, and finally visualizing them in stunning charts and graphs.