Created
December 6, 2011 15:54
-
-
Save olleman42/1438672 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| <meta charset="UTF-8"> | |
| <pre><?php | |
| //sort like a whore | |
| //sortera efter antalet f i värdet, flest blir högst | |
| //sorteringsfunktionen kontrollerar varje gång hur många f det finns i varje värde och sedan väger de 2 värdena mot varandra. | |
| // flest f hamnar längst ner | |
| $pussy = array("fkofpoin+9g890f", "k09k98jf+9jpoacmoif","fffffoof","asdfmivff"); | |
| print_r($pussy); | |
| usort($pussy, function($a,$b) { | |
| $fa = count_chars($a, 1); // visar hur ofta olika tecken kommer upp, f är nummer 102 | |
| $fb = count_chars($b, 1); | |
| //debug: | |
| print "jämför $a med $b"; | |
| if ($fa[102] > $fb[102]) { print " --" . $a . " flyttas ner (1)\n"; return 1; } else { print " -- " . $a . " flyttas upp (-1)\n"; return -1; } | |
| }); | |
| print_r($pussy); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment