```fun main(args: Array<String>) { val l...
# android
l
Copy code
fun main(args: Array<String>) {
    val list = mutableListOf(
        DemandLabel(
            id = "1",
            inputType = Constants.DemandLabelInputType.RADIO,
            type = Constants.DemandLabelType.DEFAULT,
            uniqueCode = "duration",
            name = "duration",
            items = listOf(
                DemandLabelItem(
                    id = "1ab", name = "5 min"
                ), DemandLabelItem(
                    id = "123abc", name = "10 min"
                )
            )
        ),
        DemandLabel(
            id = "2",
            inputType = Constants.DemandLabelInputType.RADIO,
            type = Constants.DemandLabelType.DEFAULT,
            uniqueCode = "level",
            name = "level",
            items = listOf(
                DemandLabelItem(
                    id = "2ab", name = "Beginner"
                ), DemandLabelItem(
                    id = "2bc", name = "All"
                )
            )
        ),
        DemandLabel(
            id = "3",
            inputType = Constants.DemandLabelInputType.RADIO,
            type = Constants.DemandLabelType.DEFAULT,
            uniqueCode = "Label 1",
            name = "Label 1",
            items = listOf(
                DemandLabelItem(
                    id = "3abc", name = "Adductors"
                ), DemandLabelItem(
                    id = "3abcdeft", name = "Calves"
                )
            )
        ),
        DemandLabel(
            id = "4",
            inputType = Constants.DemandLabelInputType.CHECKBOX,
            type = Constants.DemandLabelType.CUSTOM,
            uniqueCode = "Label 2",
            name = "Label 2",
            items = listOf(
                DemandLabelItem(
                    id = "4abc", name = "Abdominals2"
                ), DemandLabelItem(
                    id = "4abcdef", name = "Arms2"
                )
            )
        ),
    )
    val mapOfList = list.associateBy({ it.name }, { it.items })
    println(mapOfList)

    val changed = list.groupBy (
        { it.name },
        {it.items.forEach { it.id }} )
    println(changed)
}
🧵 2
I want create data:
Copy code
"level": [
    "5ed9fb3db5b5ae724237a5e0"
  ],
  "duration": [
    "5ed9fb3db5b5ae724237a5e0"
  ],
  "labels": [
    {
      "label": "5ed9fb3db5b5ae724237a5e0",
      "values": [
        "5ed9fb3db5b5ae724237a5e0"
      ]
    }
  ]
Pls help me, groupby List inside Map