From b568d14fe83e919b41452d8ae5b57a7dedc671cf Mon Sep 17 00:00:00 2001 From: Arun Persaud Date: Tue, 2 Dec 2008 23:29:29 -0800 Subject: NEW FEATURE: new sorting algorithm you can now sort your hand "low to high" and change your default using the setting dialog --- include/functions.php | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'include/functions.php') diff --git a/include/functions.php b/include/functions.php index 5c23958..466b4ae 100644 --- a/include/functions.php +++ b/include/functions.php @@ -608,21 +608,39 @@ function set_gametype($gametype) function mysort($cards,$gametype) { - usort ( $cards, "sort_comp" ); + global $PREF; + if(isset($PREF['sorting'])) + if($PREF['sorting']=='high-low') + usort ( $cards, 'sort_comp_high_low' ); + else + usort ( $cards, 'sort_comp_low_high' ); + else + usort ( $cards, 'sort_comp_high_low' ); return $cards; } -function sort_comp($a,$b) +function sort_comp_high_low($a,$b) { global $CARDS; $ALL = array(); - $ALL = array_merge($CARDS["trump"],$CARDS["diamonds"],$CARDS["clubs"], - $CARDS["hearts"],$CARDS["spades"]); + $ALL = array_merge($CARDS['trump'],$CARDS['diamonds'],$CARDS['clubs'], + $CARDS['hearts'],$CARDS['spades']); return pos_array($a,$ALL)-pos_array($b,$ALL); } +function sort_comp_low_high($a,$b) +{ + global $CARDS; + + $ALL = array(); + $ALL = array_merge($CARDS['trump'],$CARDS['diamonds'],$CARDS['clubs'], + $CARDS['hearts'],$CARDS['spades']); + + return -pos_array($a,$ALL)+pos_array($b,$ALL); +} + function can_call($what,$hash) { global $RULES; -- cgit v1.2.3-18-g5258