/** * { @inheritdoc } */ public function sort(CommandBuilder $builder, $sort) { if ("name" !== $sort) { $builder->push('-printf'); $builder->addArgs(SortHelper::getGnuSort(SortHelper::getSortVal($sort))); } // >arg('-d ') // ->arg('-f2-') $builder->push('| sort -r'); }
/** * * @param \Traversable $iterator * @param mixed $by int Id or callable * @throws Reea\FileSearcher\Bundle\Exceptions\InvalidSortArgumentException */ function __construct(\Traversable $iterator, $by) { $this->iterator = $iterator; if (is_callable($by)) { $this->sort = $by; } else { if (FALSE === SortHelper::getCallable(SortHelper::getSortVal($by))) { throw new Reea\FileSearcher\Bundle\Exceptions\InvalidSortArgumentException(); } $this->sort = SortHelper::getCallable(SortHelper::getSortVal($by)); } }