This should be simple. I am trying to sort a list that contains many BeerStat objects by a parameter. In this case I want acceding

and descending percent change.
I have this code, that I don't think is referencing my data corrector to perform a sort. The data is loaded into productsData.
ToggleSwitch(
initialLabelIndex: 0,
labels: ['ASC', 'DESC'],
minHeight: 30.0,
fontSize: 12.0,
cornerRadius: 20.0,
onToggle: (index) {
print('switched to : $index');
setState(() {
productsData.items.sort((a,b) => a.ptcchg.compareTo(b.ptcchg));
});
},
),
I think it has something to do with my data having integers 0-251, as keys. I'm not sure how to sort my data now that it is in a list.
Thank you