excel - 冒泡排序集合并忽略大小写敏感
问题描述
我正在使用冒泡排序对字符串列表进行排序。但是,如果我的列表中的一个是字符串开头的小写字母,它会将它放在列表的底部,即使该字母可能在中间。对获得预期输出有任何帮助吗?见下文:
List output: expect output:
A A
B B
C C
K e
L K
e L
冒泡排序代码:
Public Function SortCollection(colInput As Collection) As Collection
Dim iCounter As Integer
Dim iCounter2 As Integer
Dim temp As Variant
Set SortCollection = New Collection
For iCounter = 1 To colInput.Count - 1
For iCounter2 = iCounter + 1 To colInput.Count
If colInput(iCounter) > colInput(iCounter2) Then
temp = colInput(iCounter2)
colInput.Remove iCounter2
colInput.Add temp, temp, iCounter
End If
Next iCounter2
Next iCounter
Set SortCollection = colInput
End Function
解决方案
推荐阅读
- python - 从奇数 Dd HH:MM:SS.mm 格式中提取时间数据
- javascript - 伪元素操作
- git - 如何引用存储在 VSTS 或 Azure DevOps Git Repo 中的链接 ARM 模板?
- java - 使用spring-boot向java对象请求Json请求体
- powershell - 避免呼叫深度溢出失败
- javascript - Lambda 错误未被 try/catch 块或错误处理程序捕获
- java - JNDI 位置 [comp/env/test] 上可用的类型 [class java.util.Properties] 的对象不可分配给 [javax.sql.DataSource]
- python - Keras `multi_gpu_model` 使用导致错误 `yolo_head` 未定义
- unix - Go fmt 会自动缩进吗?
- ruby-on-rails - Rails NumericValueOutOfRange 显示与错误关联的字段