for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
/*
* This file is part of Symplify
* Copyright (c) 2016 Tomas Votruba (http://tomasvotruba.cz).
*/
namespace Symplify\PHP7_Sculpin\Renderable\Sorting;
use Symplify\PHP7_Sculpin\Renderable\File\PostFile;
final class PostSorter
{
/**
* @param PostFile[] $posts
*
* @return PostFile[]
public function sort(array $posts) : array
// todo: could be skipped by Finder order by name
if (count($posts) < 2) {
return $posts;
}
usort($posts, [$this, 'compareTwoPosts']);
private function compareTwoPosts(PostFile $postA, PostFile $postB) : int
return strnatcmp($postA->getDate(), $postB->getDate());