new sort function; should sorrt correctly for solos,etc
authorarun <arun@nubati.net>
Tue, 16 Jan 2007 15:00:03 +0000 (15:00 +0000)
committerarun <arun>
Tue, 16 Jan 2007 15:00:03 +0000 (15:00 +0000)
functions.php
index.php

index 221bea8f2d028d2ad6066e1a13928503b5b2c9cb..cecc63c5df74b79598cbf5f3a1e164b6a9f416b6 100644 (file)
@@ -523,4 +523,24 @@ 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;
+  }
+
+  $compare = create_function("$a, $b", "return pos_array($a,$ALL)-pos_array($b,$ALL);");
+
+  usort ( $cards, $compare );
+
+  return;
+}
+
+
 ?>
\ No newline at end of file
index f8bb305cf80957fc7e277139724e631539876cb5..ef047be0f0983f169174417b78b240a810ca9d07 100644 (file)
--- a/index.php
+++ b/index.php
@@ -667,7 +667,7 @@ else if(myisset("me"))
          }
        
        $mycards = DB_get_hand($me);
-       sort($mycards);
+       mysort($mycards,$gametype);
        echo "<div class=\"mycards\">\n";
        
        if($myturn && !myisset("card"))