|
@@ -160,8 +160,29 @@ class User extends Api
|
|
|
$res = Db::name('user_weixiu_baobei')->where('status',$type)->where('uid',$user['id'])->order('create_time')->select();
|
|
|
|
|
|
$datas = array_merge($data,$res);
|
|
|
+ # 按距离降序排序
|
|
|
+ $a = self::arraySort($datas, 'create_time', SORT_DESC);
|
|
|
+// print_r($a);die;
|
|
|
+// # 按money升序排序
|
|
|
+// $b = arraySort($data, 'money', SORT_ASC);
|
|
|
+// print_r($b);
|
|
|
+ return $this->success('',$a);
|
|
|
+ }
|
|
|
|
|
|
- return $this->success('',$datas);
|
|
|
+ /**
|
|
|
+ * 二维数组根据某个字段排序
|
|
|
+ * @param array $array 要排序的数组
|
|
|
+ * @param string $keys 要排序的键字段
|
|
|
+ * @param string $sort 排序类型 SORT_ASC SORT_DESC
|
|
|
+ * @return array 排序后的数组
|
|
|
+ */
|
|
|
+ function arraySort($array, $keys, $sort = SORT_DESC) {
|
|
|
+ $keysValue = [];
|
|
|
+ foreach ($array as $k => $v) {
|
|
|
+ $keysValue[$k] = $v[$keys];
|
|
|
+ }
|
|
|
+ array_multisort($keysValue, $sort, $array);
|
|
|
+ return $array;
|
|
|
}
|
|
|
|
|
|
/**
|