-
Notifications
You must be signed in to change notification settings - Fork 0
/
test1.php
59 lines (45 loc) · 1.25 KB
/
test1.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
class Fuckyou {
function test() {
$tags=array(
new Tag(3),
new Tag(7),
new Tag(5),
new Tag(9)
);
$flipped=array_flip($orderedids);
/*
class Sorter {
public $flipped;
function __construct($flipped) {
$this->flipped=$flipped;
}
function fsort($tag1, $tag2) {
if ($this->flipped[$tag1->id]<$this->flipped[$tag2->id]) return -1;
else if ($this->flipped[$tag1->id]==$this->flipped[$tag2->id]) return 0;
else return 1;
}
}
$sorter=new Sorter($flipped);
usort($tags, array($sorter, "fsort"));
*/
function t($flipped){
return self::t($flipped);
};
return t($flipped);
}
function fsort($tag1, $tag2) {
if ($this->flipped[$tag1->id]<$this->flipped[$tag2->id]) return -1;
else if ($this->flipped[$tag1->id]==$this->flipped[$tag2->id]) return 0;
else return 1;
}
}
class Tag {
public $id;
function __construct($id) {
$this->id=$id;
}
}
$f=new Fuckyou();
$rtags=$f->test();
foreach ($rtags as $tag) echo $tag->id." ";