-
Notifications
You must be signed in to change notification settings - Fork 1
/
sort.php
76 lines (70 loc) · 1.73 KB
/
sort.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
function dsort( $a, $b )
{
return strcasecmp( basename( $a["directory"] ), basename( $b["directory"] ) );
}
function fsort( $a, $b )
{
return strcasecmp( basename( $a["file"] ), basename( $b["file"] ) );
}
function msort( $a, $b )
{
global $sort_array, $ordered;
$i = "0";
$ret = "0";
// While not filenames_only, while in the first 7 sort_arrays and if ret is 0
while( $i < count( $sort_array ) && $ret == "0" )
{
if( ! isset( $a[ ($sort_array[$i]) ] ) && isset( $b[ ($sort_array[$i]) ] ))
{
$ret = -1;
}
else if( ! isset( $b[ ($sort_array[$i]) ] ))
{
$ret = 1;
}
else if( strcmp( $sort_array[$i], "Track" ) == "0" || strcmp( $sort_array[$i], "Time" ) == "0" )
{
if( strcmp( $ordered, "yes" ))
{
$ret = strnatcmp( $a[ ($sort_array[$i]) ], $b[ ($sort_array[$i]) ] );
}
else
{
$ret = strnatcmp( $b[ ($sort_array[$i]) ], $a[ ($sort_array[$i]) ] );
}
}
else
{
if( strcmp( $ordered, "yes" ))
{
$ret = strcasecmp( $a[ ($sort_array[$i]) ], $b[ ($sort_array[$i]) ] );
}
else
{
$ret = strcasecmp( $b[ ($sort_array[$i]) ], $a[ ($sort_array[$i]) ] );
}
}
$i++;
}
return $ret;
}
/***********************************************************************************************************************#
# #
# pickSort(): Simply this takes $pick and makes it the first value in a string containing array $sort_array #
# #
#***********************************************************************************************************************/
function pickSort( $pick )
{
global $sort_array;
$ret = $pick;
foreach( $sort_array as $value )
{
if( strncmp( $pick, $value, strlen( $pick )))
{
$ret .= "," . $value;
}
}
return $ret;
}
?>