group by and order by not working
<p>I am trying to get group by and order by to work together but no luck could someone tell me what I am doing wrong.</p>

<pre><code>$get1_msg1 = mysqli_query($con, "select * from (select message_id, sender, receiver, message, read_status, time_sent from user_messages where receiver='".$_SESSION['userid']."' order by time_sent desc ) as temp group by sender order by time_sent desc ");
</code></pre>

<p>I am not sure what i am doing wrong.</p>