Last active
January 3, 2016 22:16
-
-
Save kitek/1388238 to your computer and use it in GitHub Desktop.
Sortowanie tablicy wielowymiarowej
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
// 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