Created
July 10, 2016 19:11
-
-
Save rossriley/59d943fe9bd25ee57c8652dc58ba7232 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Assuming you have a repeater field named `performances` and within each set there's a field named performancetime which is a datetime. | |
// The example is in PHP code, if you want to use it in Twig then you'll need to put this code in a method and use a Twig Filter to point | |
// to the method | |
$iterator = $record['performances']->getIterator(); | |
$iterator->uasort(function ($first, $second) { | |
if ($first === $second) { | |
return 0; | |
} | |
return (float) $first->get('performancetime')->format("U.u") < (float) $second->get('performancetime')->format("U.u") ? -1 : 1; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment