# Contain order does not match

**URL:** <https://discourse.cakephp.org/t/contain-order-does-not-match/9393>\
**Category:** Need Help\
**Created:** [June 1, 2021, 10:24pm UTC](https://discourse.cakephp.org/t/contain-order-does-not-match/9393 "2021-06-01T22:24:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![6120](https://avatars.discourse-cdn.com/v4/letter/6/278dde/32.png) [@6120](https://discourse.cakephp.org/u/6120)\
**Post date:** [June 1, 2021, 10:24pm UTC](https://discourse.cakephp.org/t/contain-order-does-not-match/9393/1 "2021-06-01T22:24:45Z")

</div>

Good night everybody …  
Here is some code :

```auto
$this->paginate = [
            'contain' => [
                'Categories',
                'Users',
                'Tags' => function($q) {
                    return $q->select(['Tags.id', 'Tags.name'])->order(['Tags.name' => 'asc']);
                },
            'order' => ['Articles.name' => 'asc'],
            'limit' => [50]
        ];

```

Tags are not sorted so what’s wrong ?

---

<div class="post-metadata">

**Author:** ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)\
**Post date:** [June 1, 2021, 11:38pm UTC](https://discourse.cakephp.org/t/contain-order-does-not-match/9393/2 "2021-06-01T23:38:54Z")

</div>

If you look at the generated query, is it right? If you add something like a `->limit(1)`, does that have an effect? (Not suggesting that as a “fix”, but as a way to tell whether it’s the `order` part that’s failing, or something deeper.)

---

<div class="post-metadata">

**Author:** ![6120](https://avatars.discourse-cdn.com/v4/letter/6/278dde/32.png) [@6120](https://discourse.cakephp.org/u/6120)\
**Post date:** [June 2, 2021, 3:15am UTC](https://discourse.cakephp.org/t/contain-order-does-not-match/9393/3 "2021-06-02T03:15:31Z")

</div>

Thank you for replying.

Sorry, this list does not come from this method.  
It comes from an ajax call so that I have two lists ordered differently.

Sorry for wasting your time and thank you again.  
Often, when facing a problem, you end up not seing the right place.
