Skip to content

Instantly share code, notes, and snippets.

@kovaldn
Created January 22, 2014 19:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kovaldn/8565817 to your computer and use it in GitHub Desktop.
Save kovaldn/8565817 to your computer and use it in GitHub Desktop.
PHP: Sorting an array of objects
// key - заменить на ключ, по которому необходимо выполнить сортировку
// uasort – сортирует массив, используя пользовательскую функцию mySort
function mySort($f1,$f2)
{
if($f1->key < $f2->key) return -1;
elseif($f1->key > $f2->key) return 1;
else return 0;
}
uasort($mass,"mySort");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment