deltoideus wrote in php

stuck...

Hi. Could anyone help with my problem.
I have an array of Objects and i want to sort it
by $Object->MDate value. MDate has a format:
yyyy-mm-dd.

i tried

but it keeps telling me: Warning: usort(): Invalid comparison function...

class MyClass {

  usort($objects_array, 'my_compare');

  function my_compare ($a, $b) {
    $dateA = str_replace('-', '', $a);
    $dateB = str_replace('-', '', $b);
    if ($dateA == $dateB) {
        return 0;
    } elseif ($dateA < $dateB) {
        return -1;
    } else {
        return 1;
    }
  }

}