Ken 4 giorni fa
parent
commit
9d66239d8e
2 ha cambiato i file con 29 aggiunte e 1 eliminazioni
  1. 27 0
      app/Helpers/helpers.php
  2. 2 1
      app/Services/BetService.php

+ 27 - 0
app/Helpers/helpers.php

@@ -2,6 +2,33 @@
 
 use Illuminate\Support\Facades\Lang;
 
+if (!function_exists('custom_sort')) {
+    function custom_sort($a, $b)
+    {
+        // 定义排序规则
+        $order = [
+            '大', '小', '单', '双', '大单', '大双', '小单', '小双',
+            '0A', '1A', '2A', '3A', '4A', '5A', '6A', '7A', '8A', '9A',
+            '0B', '1B', '2B', '3B', '4B', '5B', '6B', '7B', '8B', '9B',
+            '0C', '1C', '2C', '3C', '4C', '5C', '6C', '7C', '8C', '9C',
+            '0操', '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操'
+        ];
+
+        // 找出每个元素的排序位置
+        $index_a = array_search($a, $order);
+        $index_b = array_search($b, $order);
+
+        // 如果找不到,则按字母和数字升序排列
+        if ($index_a === false && $index_b === false) {
+            return strcmp($a, $b);
+        }
+
+        return $index_a - $index_b;
+    }
+}
+
 if (!function_exists('lang')) {
     function lang(string $key): string
     {

+ 2 - 1
app/Services/BetService.php

@@ -1061,7 +1061,8 @@ class BetService extends BaseService
         $text3 .= lang("玩法") . "    " . lang("总投") . " \n";
         App::setLocale($lang);
         if ($keywordsList) {
-            ksort($keywordsList);
+            uksort($keywordsList, 'custom_sort');
+//            ksort($keywordsList);
             foreach ($keywordsList as $k => $v) {
                 $text3 .= "{$k}    {$v} \n";
             }