diff options
Diffstat (limited to 'etc/inc/util.inc')
-rw-r--r-- | etc/inc/util.inc | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/etc/inc/util.inc b/etc/inc/util.inc index 818b08e..85bf991 100644 --- a/etc/inc/util.inc +++ b/etc/inc/util.inc @@ -996,4 +996,29 @@ function timeout($timer = 9) { return $key; } -?> +function msort($array, $id="id", $sort_ascending=true) { + $temp_array = array(); + while(count($array)>0) { + $lowest_id = 0; + $index=0; + foreach ($array as $item) { + if (isset($item[$id])) { + if ($array[$lowest_id][$id]) { + if (strtolower($item[$id]) < strtolower($array[$lowest_id][$id])) { + $lowest_id = $index; + } + } + } + $index++; + } + $temp_array[] = $array[$lowest_id]; + $array = array_merge(array_slice($array, 0,$lowest_id), array_slice($array, $lowest_id+1)); + } + if ($sort_ascending) { + return $temp_array; + } else { + return array_reverse($temp_array); + } +} + +?>
\ No newline at end of file |