Skip to content

Instantly share code, notes, and snippets.

@kitek
Last active January 3, 2016 22:16
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 kitek/1388238 to your computer and use it in GitHub Desktop.
Save kitek/1388238 to your computer and use it in GitHub Desktop.
Sortowanie tablicy wielowymiarowej
<?
// Proste sortowanie tablicy wielowymiarowej w obiekcie
// (w tym przypadku sortujemy malejąco po wymiarze 'similar')
class klasa {
public sortuj() {
usort($tablicaDoSortowania, array('klasa','compare'));
}
public function compare($a, $b) {
if ($a['similar'] == $b['similar']) {
return 0;
}
return ($a['similar'] > $b['similar']) ? -1 : 1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment