首页 > 解决方案 > 如何按数值对 json 进行排序?

问题描述

我将如何按数值将 json 排序到数组中,然后如何轻松访问该信息。

{"362439239671087109":{"coins":19},"178538363954003968":{"coins":18},"234255082345070592":{"coins":137}} 

奇怪的数字是不和谐的用户 ID。

标签: javascriptjsonsortingnumericdiscord.js

解决方案


嗯。首先,制作关联数组,如果json是从bakcend生成的,例如在php中,您可以使用函数来制作订单数组。---> http://php.net/manual/en/array.sorting.php 见: Converting JavaScript object with numeric keys into array


推荐阅读