{"action":"opened","issue":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/8448","labels_url":"https://api.github.com/repos/yiisoft/yii2/issues/8448/labels{/name}","comments_url":"https://api.github.com/repos/yiisoft/yii2/issues/8448/comments","events_url":"https://api.github.com/repos/yiisoft/yii2/issues/8448/events","html_url":"https://github.com/yiisoft/yii2/issues/8448","id":77304016,"number":8448,"title":"ActiveRecord using joinWith and sorting on joined table columns comes back wrong","user":{"login":"ptheofan","id":880939,"avatar_url":"https://avatars.githubusercontent.com/u/880939?v=3","gravatar_id":"","url":"https://api.github.com/users/ptheofan","html_url":"https://github.com/ptheofan","followers_url":"https://api.github.com/users/ptheofan/followers","following_url":"https://api.github.com/users/ptheofan/following{/other_user}","gists_url":"https://api.github.com/users/ptheofan/gists{/gist_id}","starred_url":"https://api.github.com/users/ptheofan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ptheofan/subscriptions","organizations_url":"https://api.github.com/users/ptheofan/orgs","repos_url":"https://api.github.com/users/ptheofan/repos","events_url":"https://api.github.com/users/ptheofan/events{/privacy}","received_events_url":"https://api.github.com/users/ptheofan/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-05-17T12:48:32Z","updated_at":"2015-05-17T12:48:32Z","closed_at":null,"body":"I am running the following (please note that column ```ts``` belongs to table ```activity``` and not ```player```)\r\n\r\n```\r\n        $players = Player::find()\r\n            ->joinWith(['activities'])\r\n            ->where(['player.id' => 12])\r\n            ->orderBy(['ts' => SORT_ASC])\r\n            ->all();\r\n```\r\n\r\nand then noticed my records don't come back sorted. Checking on Yii debug I see it actually runs the following (which is correct according to the documentation)\r\n\r\n```\r\nSELECT `player`.* FROM `player` LEFT JOIN `activity` ON `player`.`id` = `activity`.`user_id` WHERE `player`.`id`=12 ORDER BY `ts`\r\n```\r\nand\r\n```\r\nSELECT * FROM `activity` WHERE `user_id`=12\r\n```\r\n\r\nIs there some way that I can use the joinWith (maintaining the nice and clear syntax) and still have it return the records correctly?"}}