How to do a simple PHP Multisort
<p>From the queried database, we got this</p>

<pre><code>foreach ($child_posts as $child_post) {
 $child_id = $child_post-&gt;ID;
 $dayOfWeek = get_post_meta($child_id,'wpcf-day-of-week', true);
 $time = get_post_meta($child_id,'wpcf-time', true);

$class[] = array('day' =&gt; $dayOfWeek, 'time' =&gt; $time, 'value' =&gt; $child_id);
}

{"classes":[
{"day":"7","time":"1500","value":13574},
{"day":"7","time":"1800","value":13573},
{"day":"4","time":"1900","value":11346},
{"day":"6","time":"1100","value":11494},
{"day":"5","time":"1800","value":11362},
{"day":"7","time":"1700","value":13572},
{"day":"6","time":"1600","value":11498},
{"day":"6","time":"1500","value":11496}]}
</code></pre>

<p>Day = Mon - Sun</p>

<p>Time = Military time</p>

<p>Value = something I need, but do not need sorting</p>

<p>I need to sort first by day, then by time. And get back the database in the format like how it was</p>

<pre><code>{"classes":[
{"day":"4","time":"1900","value":11346},
{"day":"5","time":"1800","value":11362},
{"day":"6","time":"1100","value":11494},
{"day":"6","time":"1500","value":11496},
{"day":"6","time":"1600","value":11498},
{"day":"7","time":"1500","value":13574},
{"day":"7","time":"1700","value":13572},
{"day":"7","time":"1800","value":13573}]}
</code></pre>

<p>I tried using the method in the php manual but I still can't really get it.</p>

<p>This is what I did</p>

<pre><code>foreach ($class as $key =&gt; $row) {
    $day[$key]  = $row['day'];
    $time[$key] = $row['time'];
    $value[$key] = $row['value'];

}

$class[] = array_multisort($day, SORT_DESC, $time, SORT_ASC, $class);
</code></pre>

<p>I'm know what I should expect, but I don't know how to go around getting it. Hopefully someone can help out here :)</p>

<p>My orignial script:
    

<pre><code> $childargs = array(
 'post_type' =&gt; 'class',
 'numberposts' =&gt; -1,
 'meta_query' =&gt; array(array('key' =&gt; '_wpcf_belongs_instructor_id', 'value' =&gt; $instructor_post_id))
 );
 $child_posts = get_posts($childargs);

 //$child_posts = types_child_posts(‘class’);
 foreach ($child_posts as $child_post) {
  $child_id = $child_post-&gt;ID;
  $dayOfWeek = get_post_meta($child_id,'wpcf-day-of-week', true);
  $time = get_post_meta($child_id,'wpcf-time', true);

 $class[] = array('day' =&gt; $dayOfWeek, 'time' =&gt; $time, 'value' =&gt; $child_id);
 }

 echo json_encode(
   array("classes" =&gt; $class)
 )
 ?&gt;
</code></pre>
