import "dart:collection";
main() {
final SplayTreeMap st =
SplayTreeMap();
st["yyy"] = {"should be" : "3rd"};
st["zzz"] = {"should be" : "last"};
st["aaa"] = {"should be" : "first"};
st["bbb"] = {"should be" : "2nd"};
for (final String key in st.keys) {
print("$key : ${st[key]}");
}
}
// Output:
// aaa : first
// bbb : 2nd
// yyy : 3rd
// zzz : last
如果您想要对List对map的键进行排序:
var sortedKeys = map.keys.toList()..sort();