From 34b2b5ea5e502686deb9f7672c92e8729157bfe5 Mon Sep 17 00:00:00 2001 From: arun Date: Tue, 16 Jan 2007 15:11:17 +0000 Subject: fixed the new sorting algorithm --- functions.php | 22 +++++++++------------- index.php | 2 +- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/functions.php b/functions.php index cecc63c..45416a7 100644 --- a/functions.php +++ b/functions.php @@ -525,22 +525,18 @@ function set_gametype($gametype) function mysort($cards,$gametype) { - global $TRUMP,$DIAMONDS,$HEARTS,$CLUBS,$SPADES; - - switch($gametype) { - case normal: - case trump: - default: - $ALL = array_merge($TRUMP,$DIAMONDS,$CLUBS,$HEARTS,$SPADES,$DIAMONDS); - break; - } + usort ( $cards, "sort_comp" ); + return $cards; +} - $compare = create_function("$a, $b", "return pos_array($a,$ALL)-pos_array($b,$ALL);"); +function sort_comp($a,$b) +{ + global $TRUMP,$DIAMONDS,$HEARTS,$CLUBS,$SPADES; - usort ( $cards, $compare ); + $ALL = array(); + $ALL = array_merge($TRUMP,$DIAMONDS,$CLUBS,$HEARTS,$SPADES,$DIAMONDS); - return; + return pos_array($a,$ALL)-pos_array($b,$ALL); } - ?> \ No newline at end of file diff --git a/index.php b/index.php index ef047be..6353f34 100644 --- a/index.php +++ b/index.php @@ -667,7 +667,7 @@ else if(myisset("me")) } $mycards = DB_get_hand($me); - mysort($mycards,$gametype); + $mycards = mysort($mycards,$gametype); echo "
\n"; if($myturn && !myisset("card")) -- cgit v1.2.3-18-g5258