简体   繁体   中英

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.

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.

Try using the array type? Or add a field to identify the order

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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