0
    [
      {
        "1": {
          "name": "Shahed Emon",
          "win_rate": "98.7%"
        }
      },
      {
        "2": {
          "name": "Mustakim Nahid",
          "win_rate": "88.7%"
        }
      },
      {
        "3": {
          "name": "Imtiaz Rizan",
          "win_rate": "72.3%"
        }
      },
      {
        "4": {
          "name": "Ishtiak Rongon",
          "win_rate": "52.6%"
        }
      },
      {
        "5": {
          "name": "Sazzad Evan",
          "win_rate": "99.2%"
        }
      },
      {
        "6": {
          "name": "Tanjil Dewan",
          "win_rate": "91.1%"
        }
      }
    ]

Can anyone help me parse this & sort it by 'win_rate' in dart? Or guide me how to model the integer object keys like "1", "2", "3",....

I am having trouble because object keys are integer itself.

  • Try [this](https://stackoverflow.com/q/33758601/3022836) – Kunu Mar 07 '20 at 11:04
  • Parse JSON using `jsonDecode`. Sort the list using `List.sort`. Maybe use a comparison like `(a, b) => a.values.first["win_rate"].compareTo(b.values.first["win_rate"])`. That requires the win rate percentage to have leading zeros for percentages < 10, otherwise you need to parse the numbers. – lrn Mar 07 '20 at 17:49
  • Thank you..can explain what .first working here as? – Shahed Emon Mar 09 '20 at 08:18

0 Answers0