按时间对json表进行排序

时间:2018-12-11 14:06:46

标签: javascript botkit

。 您好

我有这个json文件:

{
  "fbl": {
    "id": "fbl",
    "user_id": "fbl@xxx.fr",
    "nb_error": 0,
    "time": "1:27.700"
  },
  "dev": {
    "id": "dev",
    "user_id": "dev@xxx.fr",
    "nb_error": 0,
    "time": "1:12.54"
  },
  "jul": {
    "id": "jul",
    "user_id": "jul@xx.fr",
    "nb_error": 0,
    "time": "0:58.700"
  }
}

我想读取此文件并按最短时间到最长时间的顺序对其进行排序(请勿修改该文件,只需检索排序的值以使用botkit显示它们即可)。

首先,我使用以下文件进行读取:

fs.readFileSync('course.json/quiz.json', 'utf8');

这是一个好选择吗?

您能帮我对这些值进行排序然后显示出来吗?

谢谢

1 个答案:

答案 0 :(得分:0)

如果要更改顺序,只需翻转比较器功能中的值

<ImageBackground
    imageStyle={{
        bottom: 40 // Whatever offset you want from the bottom
    }}
/>