I need to sort common age names as sublist to the same age list item here below is the list which contains age and name , here i want to make sublist names to the same age item , need help
class Details {
final String name;
final int age;
Details(this.name, this.age);
List <Details> list = [
{ Jack, 21},
{ Adam, 22},
{ Katherin, 24},
{ john, 22},
{ mike, 21}
]
}
Expected :
List <Details> list = [
{ 21: ["jack", "mike",]},
{ 22: ["Adam", "john"]},
{ 24: ["Katherin"]}, ]