Giter Site home page Giter Site logo

Person credit order about laravel HOT 2 CLOSED

php-tmdb avatar php-tmdb commented on June 7, 2024
Person credit order

from laravel.

Comments (2)

wtfzdotnet avatar wtfzdotnet commented on June 7, 2024

Hi @rifats ,

I've only noticed your ticket earlier and took a look under the hood of our main libray php-tmdb/api. This functionality was not present yet but thanks to this php-tmdb/api@55dc12f commit you can now sort any collection.

So please make sure you have version 2.0.11 of the php-tmdb/api library installed, then try the following:

$person->sort(function($a, $b){
    if ($a->getReleaseDate() == $b->getReleaseDate()) {
        return 0;
    }

    return $a->getReleaseDate() > $b->getReleaseDate() ? 1 : -1;
});

Have a great weekend!

from laravel.

rifats avatar rifats commented on June 7, 2024

@wtfzdotnet , thank you for the hint!
I realized that the API does not implement sorting. And yesterday I did so (for CombinedCredits):

usort($credits['cast'],  array($this, "compareReleaseDate"));

function compareReleaseDate($a, $b)
    {
        $a_date = (array_key_exists('release_date', $a)) ? $a['release_date'] : $a['first_air_date'];
        $b_date = (array_key_exists('release_date', $b)) ? $b['release_date'] : $b['first_air_date'];
        return strnatcmp($b_date,$a_date);
    }

from laravel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.