0

I'm retrieving a list of people via Basecamp API classic, except it seems to come ordered by ID. I followed the documentation to do so, here is a simplified version of the echoing part:

foreach($persons as $person) {
    $firstName = $person->getFirstname();
    $lastName = $person->getLastname();

    echo $firstName.' '.$lastName;
}

Any idea how I could order this list by alphabetical order?

Thanks for your help.

morgi
  • 1,005
  • 3
  • 17
  • 24

1 Answers1

0

You can use the sort() function on $persons

http://uk.php.net/manual/en/function.sort.php

EDIT: Oh, wait, can you show a print_r() of $persons?

Prash
  • 1,915
  • 3
  • 20
  • 32
  • I tried that, it outputs the following error: "Warning: sort() expects parameter 1 to be array, object". – morgi Nov 30 '12 at 18:40
  • Yeah, I realised that with my edit. Please provide the print_r or var_dump of $persons. – Prash Nov 30 '12 at 19:41