android - 如何在飞镖中使用正则表达式对字符串列表进行排序?
问题描述
我本质上是在寻找除 .sort() 之外的另一种对字符串列表进行排序的方法,出于我的目的,type '_SecItem' is not a subtype of type 'Comparable<dynamic>'
我正在尝试通过字符串前面的数字对字符串列表进行排序。就像是:
List<String> hi = ['05stack', '03overflow', '01cool','04is', '02uToo'];
对此:
['01cool', '02uToo', '03overflow', '04is', '05stack']
解决方案
我可以使用 sort() 轻松排序。
var List<String> hi = ['05stack', '03overflow', '01cool', '04is', '02uToo'];
hi.sort();
hi.forEach((element) {
print(element);
});
它打印:
01cool
02uToo
03overflow
04is
05stack
我没有收到任何错误
type '_SecItem' is not a subtype of type 'Comparable<dynamic>'
推荐阅读
- swift - Swift:如何确保按钮将图像返回到以前的状态
- php - 如何通过 PHP 将大型 CSV 文件导入 MySQL?
- javascript - Javascript: SyntaxError: await 仅在异步函数中有效
- javascript - 表格未附加到内容
- python - Swift任务打开管道的文件描述符
- jquery - 单击 Bootstrap 中的单选按钮时如何显示/隐藏文本
- validation - Buefy b-checkbox 和 VeeValidate
- python-3.x - 获取节点的二、三阶邻居
- python - Kivy on_press 与 on_touch_down
- react-native - react-native-video TypeError:未定义不是对象