简体   繁体   English

防止 JSON 对象在 ReactJS 中按字母顺序排序

[英]Preventing JSON objects from ordering alphabetically in ReactJS

I'm having an issue wherein JSON automatically alphabetizing stored data is giving me a lot of trouble.我遇到了一个问题,其中 JSON 自动按字母顺序排列存储的数据给我带来了很多麻烦。

Using使用

    <FormControl component="fieldset">
      <FormLabel component="legend">Days of the Week</FormLabel>
      <FormGroup aria-label="position" row>
        {Object.keys(days).map(key => {
          return (
            <FormControlLabel
              key={key}
              checked={days[key]}
              onChange={event => changed({ [key]: event.target.checked })}
              control={<Checkbox color="primary" />}
              label={key}
              labelPlacement="top"
            />
          );
        })}
      </FormGroup>
    </FormControl>
  );

I end up with my days being displaced a Friday, Monday, Saturday, Sunday, Thursday, Tuesday, Wednesday最后我的日子在周五、周一、周六、周日、周四、周二、周三被取代

I've come across solutions to similar problems for C, Python, and others but not for ReactJS unfortunately, any help would be appreciated.我遇到了 C、Python 等类似问题的解决方案,但不幸的是,ReactJS 没有遇到类似问题,任何帮助将不胜感激。

Try using the array type?尝试使用数组类型? Or add a field to identify the order或者添加一个字段来标识订单

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM